Unverified Commit 535dc9ef authored by Kerwin's avatar Kerwin Committed by GitHub

Added dlink-daemon module code style. (#918)

parent 56f235d3
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.constant;
public interface FlinkTaskConstant {
......
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.entity;
import java.util.LinkedList;
......@@ -28,7 +27,6 @@ public class TaskQueue<T> {
private final Object lock = new Object();
public void enqueue(T task) {
synchronized (lock) {
lock.notifyAll();
......
......@@ -17,10 +17,10 @@
*
*/
package com.dlink.daemon.entity;
import com.dlink.daemon.task.DaemonTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,7 +37,7 @@ public class TaskWorker implements Runnable {
@Override
public void run() {
// log.info("TaskWorker run");
//log.info("TaskWorker run");
while (running) {
DaemonTask daemonTask = queue.dequeue();
if (daemonTask != null) {
......@@ -51,7 +51,7 @@ public class TaskWorker implements Runnable {
}
public void shutdown() {
// log.info(Thread.currentThread().getName() + "TaskWorker shutdown");
//log.info(Thread.currentThread().getName() + "TaskWorker shutdown");
running = false;
}
}
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.exception;
public class DaemonTaskException extends RuntimeException {
......
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.pool;
import com.dlink.daemon.entity.TaskQueue;
......@@ -32,7 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* @author lcg
* @operate
* @date 2022/3/7 10:36
* @return
*/
public class DefaultThreadPool implements ThreadPool {
......@@ -77,7 +75,9 @@ public class DefaultThreadPool implements ThreadPool {
synchronized (lock) {
if (num + this.workerNum.get() > MAX_WORKER_NUM) {
num = MAX_WORKER_NUM - this.workerNum.get();
if (num <= 0) return;
if (num <= 0) {
return;
}
}
for (int i = 0; i < num; i++) {
TaskWorker worker = new TaskWorker(queue);
......@@ -95,7 +95,9 @@ public class DefaultThreadPool implements ThreadPool {
synchronized (lock) {
if (num >= this.workerNum.get()) {
num = this.workerNum.get() - MIN_WORKER_NUM;
if (num <= 0) return;
if (num <= 0) {
return;
}
}
int count = num - 1;
while (count >= 0) {
......@@ -126,7 +128,6 @@ public class DefaultThreadPool implements ThreadPool {
return queue.getTaskSize();
}
public int getWorkCount() {
synchronized (lock) {
return this.workerNum.get();
......
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.pool;
import com.dlink.daemon.task.DaemonTask;
......@@ -25,7 +24,6 @@ import com.dlink.daemon.task.DaemonTask;
/**
* @author lcg
* @operate
* @date 2022/3/7 10:36
* @return
*/
public interface ThreadPool {
......
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon.task;
import com.dlink.daemon.constant.FlinkTaskConstant;
......
......@@ -17,15 +17,14 @@
*
*/
package com.dlink.daemon.task;
import java.util.Optional;
import java.util.ServiceLoader;
import com.dlink.assertion.Asserts;
import com.dlink.daemon.exception.DaemonTaskException;
import java.util.Optional;
import java.util.ServiceLoader;
public interface DaemonTask {
static Optional<DaemonTask> get(DaemonTaskConfig config) {
......
......@@ -17,10 +17,8 @@
*
*/
package com.dlink.daemon.task;
public class DaemonTaskConfig {
private String type;
......
......@@ -17,7 +17,6 @@
*
*/
package com.dlink.daemon;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment