-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
122 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
src/main/java/ru/vk/itmo/test/dariasupriadkina/NodeThreadPoolExecutor.java
This file was deleted.
Oops, something went wrong.
27 changes: 11 additions & 16 deletions
27
src/main/java/ru/vk/itmo/test/dariasupriadkina/ServiceIml.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/ru/vk/itmo/test/dariasupriadkina/workers/CustomThreadConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package ru.vk.itmo.test.dariasupriadkina.workers; | ||
|
||
import one.nio.async.CustomThreadFactory; | ||
|
||
import java.util.concurrent.ArrayBlockingQueue; | ||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.RejectedExecutionHandler; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class CustomThreadConfig { | ||
|
||
public static final long KEEP_ALIVE_TIME = 1000L; | ||
public static final TimeUnit KEEP_ALIVE_TIME_SECONDS = TimeUnit.SECONDS; | ||
public static final int QUEUE_SIZE = 1024; | ||
public static final int THREADS = Runtime.getRuntime().availableProcessors(); | ||
public static final int SHUTDOWN_TIMEOUT_SEC = 60; | ||
|
||
private final int corePoolSize; | ||
private final int maximumPoolSize; | ||
private final int shutdownTimeoutSec; | ||
private final ArrayBlockingQueue<Runnable> workQueue; | ||
private final CustomThreadFactory threadFactory; | ||
private final RejectedExecutionHandler handler; | ||
|
||
public CustomThreadConfig(int corePoolSize, int maximumPoolSize, int queueSize, int shutdownTimeoutSec, | ||
String threadName, RejectedExecutionHandler handler) { | ||
this.corePoolSize = corePoolSize; | ||
this.maximumPoolSize = maximumPoolSize; | ||
this.workQueue = new ArrayBlockingQueue<>(queueSize); | ||
this.shutdownTimeoutSec = shutdownTimeoutSec; | ||
this.threadFactory = new CustomThreadFactory(threadName, true); | ||
this.handler = handler; | ||
} | ||
|
||
public static CustomThreadConfig baseConfig(String threadName) { | ||
return new CustomThreadConfig(THREADS * 2, THREADS * 2, | ||
QUEUE_SIZE, SHUTDOWN_TIMEOUT_SEC, threadName, new ThreadPoolExecutor.AbortPolicy()); | ||
} | ||
|
||
public int getCorePoolSize() { | ||
return corePoolSize; | ||
} | ||
|
||
public int getMaximumPoolSize() { | ||
return maximumPoolSize; | ||
} | ||
|
||
public BlockingQueue<Runnable> getWorkQueue() { | ||
return workQueue; | ||
} | ||
|
||
public int getShutdownTimeoutSec() { | ||
return shutdownTimeoutSec; | ||
} | ||
|
||
public CustomThreadFactory getThreadFactory() { | ||
return threadFactory; | ||
} | ||
|
||
public RejectedExecutionHandler getHandler() { | ||
return handler; | ||
} | ||
} |
13 changes: 6 additions & 7 deletions
13
...ina/workers/WorkerThreadPoolExecutor.java → ...ina/workers/CustomThreadPoolExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
src/main/java/ru/vk/itmo/test/dariasupriadkina/workers/WorkerConfig.java
This file was deleted.
Oops, something went wrong.