-
Notifications
You must be signed in to change notification settings - Fork 10
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
Andrey Kurilov
committed
Jan 15, 2017
1 parent
a9c0b5e
commit 1903448
Showing
13 changed files
with
133 additions
and
73 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
common/src/main/java/com/emc/mongoose/common/concurrent/NamingThreadFactory.java
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
run/src/main/java/com/emc/mongoose/run/scenario/CommandJob.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,6 @@ | |
"output" : { | ||
"path" : "/default" | ||
} | ||
}, | ||
"storage" : { | ||
"driver" : { | ||
"remote" : true | ||
} | ||
} | ||
}, | ||
"jobs" : [ | ||
|
2 changes: 1 addition & 1 deletion
2
...net/base/src/main/java/com/emc/mongoose/storage/driver/net/base/NetStorageDriverBase.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
2 changes: 1 addition & 1 deletion
2
...nio/base/src/main/java/com/emc/mongoose/storage/driver/nio/base/NioStorageDriverBase.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
75 changes: 75 additions & 0 deletions
75
ui/src/main/java/com/emc/mongoose/ui/log/NamingThreadFactory.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,75 @@ | ||
package com.emc.mongoose.ui.log; | ||
|
||
import org.apache.logging.log4j.ThreadContext; | ||
|
||
import java.lang.Thread.UncaughtExceptionHandler; | ||
import java.util.Map; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
Created by kurila on 19.07.16. | ||
*/ | ||
public class NamingThreadFactory | ||
implements ThreadFactory { | ||
|
||
protected static final UncaughtExceptionHandler exceptionHandler = (t, e) -> { | ||
synchronized(System.err) { | ||
System.err.println("Uncaught exception in the thread \"" + t.getName() + "\":"); | ||
e.printStackTrace(System.err); | ||
} | ||
}; | ||
|
||
protected final AtomicInteger threadNumber = new AtomicInteger(0); | ||
protected final String threadNamePrefix; | ||
protected final boolean daemonFlag; | ||
protected final Map<String, String> context; | ||
|
||
public NamingThreadFactory(final String threadNamePrefix) { | ||
this.threadNamePrefix = threadNamePrefix; | ||
this.daemonFlag = false; | ||
this.context = ThreadContext.getContext(); | ||
} | ||
|
||
public NamingThreadFactory( | ||
final String threadNamePrefix, final boolean daemonFlag | ||
) { | ||
this.threadNamePrefix = threadNamePrefix; | ||
this.daemonFlag = daemonFlag; | ||
this.context = ThreadContext.getContext(); | ||
} | ||
|
||
private static final class ContextAwareThread | ||
extends Thread { | ||
|
||
private final Map<String, String> context; | ||
|
||
private ContextAwareThread( | ||
final Runnable task, final String name, final Map<String, String> context | ||
) { | ||
super(task, name); | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public final void run() { | ||
ThreadContext.putAll(context); | ||
super.run(); | ||
} | ||
} | ||
|
||
@Override | ||
public Thread newThread(final Runnable task) { | ||
final Thread t = new ContextAwareThread( | ||
task, threadNamePrefix + "#" + threadNumber.incrementAndGet(), context | ||
); | ||
t.setDaemon(daemonFlag); | ||
t.setUncaughtExceptionHandler(exceptionHandler); | ||
return t; | ||
} | ||
|
||
@Override | ||
public final String toString() { | ||
return threadNamePrefix; | ||
} | ||
} |