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