本文整理汇总了Java中scouter.util.ThreadUtil类的典型用法代码示例。如果您正苦于以下问题:Java ThreadUtil类的具体用法?Java ThreadUtil怎么用?Java ThreadUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThreadUtil类属于scouter.util包,在下文中一共展示了ThreadUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import scouter.util.ThreadUtil; //导入依赖的package包/类
@Override
public void run() {
while (brun) {
long now = System.currentTimeMillis();
Enumeration<String> en = writingBlockTable.keys();
while (en.hasMoreElements()) {
String key = en.nextElement();
Block bk = writingBlockTable.get(key);
if (bk == null)
continue;
if (now > bk.lastAccessTime + 10000 && bk.dirty) {
IOChannel.getInstance().store(bk);
bk.lastAccessTime = System.currentTimeMillis();
}
}
for (int i = 0; i < 100 && brun; i++) {
ThreadUtil.sleep(100);
}
}
}
示例2: threadDump
import scouter.util.ThreadUtil; //导入依赖的package包/类
private static List<String> threadDump() throws Throwable {
List<String> out = null;
//Java 1.5 or IBM JDK
if (SystemUtil.IS_JAVA_1_5||SystemUtil.JAVA_VENDOR.startsWith("IBM")) {
out = ThreadUtil.getThreadDumpList();
return out;
}
ClassLoader loader = LoaderManager.getToolsLoader();
if (loader == null) {
out = ThreadUtil.getThreadDumpList();
return out;
}
try {
Class<?> c = Class.forName(TOOLS_MAIN, true, loader);
IToolsMain toolsMain = (IToolsMain) c.newInstance();
out = (List<String>) toolsMain.threadDump(0, 100000);
} catch (Exception e) {
e.printStackTrace();
}
return out;
}
示例3: waitOnExit
import scouter.util.ThreadUtil; //导入依赖的package包/类
private static void waitOnExit(Server server) throws Exception {
File exit = new File(SysJMX.getProcessPID() + ".scouter");
try {
exit.createNewFile();
} catch (Exception e) {
String tmp = System.getProperty("user.home", "/tmp");
exit = new File(tmp, SysJMX.getProcessPID() + ".scouter.run");
try {
exit.createNewFile();
} catch (Exception k) {
System.exit(1);
}
}
exit.deleteOnExit();
System.out.println("System JRE version : " + System.getProperty("java.version"));
while (true) {
if (exit.exists() == false) {
server.setStopTimeout(3000);
server.stop();
System.exit(0);
}
ThreadUtil.sleep(1000);
}
}
示例4: threadDump
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static synchronized void threadDump(PrintWriter out) throws Throwable {
activeStack = true;
if (SystemUtil.IS_JAVA_1_5 || SystemUtil.JAVA_VENDOR.startsWith("IBM")) {
out.print(ThreadUtil.getThreadDump());
return;
}
ClassLoader loader = LoaderManager.getToolsLoader();
if (loader == null) {
out.print(ThreadUtil.getThreadDump());
return;
}
try {
Class c = Class.forName(TOOLS_MAIN, true, loader);
IToolsMain toolsMain = (IToolsMain) c.newInstance();
toolsMain.threadDump(out);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: endPut
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static void endPut(Map map) {
int size = map.size();
if(size > 0 && size % conf._hook_map_impl_warning_size == 0) {
TraceContext ctx = TraceContextManager.getContext();
if(ctx == null) return;
if(ctx.error != 0) return;
MapValue mv = new MapValue();
mv.put(AlertPack.HASH_FLAG + TextTypes.SERVICE + "_service-name", ctx.serviceHash);
String message = "Too many Map entries!\n" + ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2);
HashedMessageStep step = new HashedMessageStep();
step.hash = DataProxy.sendHashedMessage(message);
step.value = size;
step.start_time = (int) (System.currentTimeMillis() - ctx.startTime);
ctx.profile.add(step);
mv.put(AlertPack.HASH_FLAG + TextTypes.HASH_MSG + "_full-stack", step.hash);
DataProxy.sendAlert(AlertLevel.WARN, "TOO_MANY_MAP_ENTRIES", "too many Map entries, over #" + size, mv);
int errorMessageHash = DataProxy.sendError("too many Map entries, over #" + size);
if (ctx.error == 0) {
ctx.error = errorMessageHash;
}
ctx.offerErrorEntity(ErrorEntity.of(tooManyCollectionMemebers, errorMessageHash, 0, 0));
}
}
示例6: add
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static void add(byte[] ipaddr, int port, int serviceHash, long txid) {
long key = mkey(ipaddr, port);
Info info = socketMap.get(key);
if (info != null) {
if (info.stackOrder) {
info.service = serviceHash;
info.txid = txid;
info.stackOrder = false;
info.stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 3);
}
if (info.service == 0) {
info.service = serviceHash;
info.txid = txid;
}
info.count++;
} else {
info = new Info(serviceHash, txid);
socketMap.put(key, info);
if (port == Configure.getInstance()._trace_fullstack_socket_open_port) {
info.stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 3);
}
}
}
示例7: run
import scouter.util.ThreadUtil; //导入依赖的package包/类
public void run() {
while (true) {
ThreadUtil.sleep(1000);
if (conf.counter_enabled == false) {
continue;
}
long now = System.currentTimeMillis();
CounterBasket pw = new CounterBasket();
for (int i = 0; i < taskSec.size(); i++) {
CountStat r = taskSec.get(i);
try {
if (r.counter.interval() <= now - r.xtime) {
r.xtime = now;
r.counter.process(pw);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
//
PerfCounterPack[] pks = pw.getList();
DataProxy.sendCounter(pks);
}
}
示例8: threadList
import scouter.util.ThreadUtil; //导入依赖的package包/类
@RequestHandler(OBJECT_THREAD_LIST)
public Pack threadList(Pack param) {
MapPack mpack = ThreadUtil.getThreadList();
ListValue ids = mpack.getList("id");
ListValue txid = mpack.newList("txid");
ListValue elapsed = mpack.newList("elapsed");
ListValue service = mpack.newList("service");
for (int i = 0; i < ids.size(); i++) {
long tid = CastUtil.clong(ids.get(i));
TraceContext ctx = TraceContextManager.getContext(tid);
if (ctx != null) {
txid.add(new TextValue(Hexa32.toString32(ctx.txid)));
service.add(new TextValue(ctx.serviceName));
long etime = System.currentTimeMillis() - ctx.startTime;
elapsed.add(new DecimalValue(etime));
} else {
txid.add(new NullValue());
elapsed.add(new NullValue());
service.add(new NullValue());
}
}
return mpack;
}
示例9: run
import scouter.util.ThreadUtil; //导入依赖的package包/类
public void run() {
DataUdpAgent udp = DataUdpAgent.getInstance();
while (running) {
int size = queue.size();
switch (size) {
case 0:
ThreadUtil.sleep(conf.net_udp_collection_interval_ms);
break;
case 1:
udp.write(queue.pop());
break;
default:
send(udp, size);
break;
}
}
}
示例10: run
import scouter.util.ThreadUtil; //导入依赖的package包/类
public void run() {
long last = System.currentTimeMillis();
while (true) {
long now = System.currentTimeMillis();
if (now > last + DateUtil.MILLIS_PER_HOUR) {
last = now;
clearOldLog();
}
if (lastDataUnit != DateUtil.getDateUnit()) {
pw = (PrintWriter) FileUtil.close(pw);
lastDataUnit = DateUtil.getDateUnit();
}
ThreadUtil.sleep(5000);
}
}
示例11: addMax
import scouter.util.ThreadUtil; //导入依赖的package包/类
public synchronized void addMax(int activeService, float heapTotal, float heapUsed, int recentUser, int serviceCount, float apiTps, float sqlTps, float tps) {
while (true) {
if (isProcessing) {
ThreadUtil.sleep(10);
} else {
break;
}
}
if (heapTotal > 0f && this.heapTotal < heapTotal) {
this.heapTotal = heapTotal;
}
// 5분 내 최대 값 갱신
if (activeService > maxActiveService) {
maxActiveService = activeService;
}
if (heapUsed > maxHeapUsed) {
maxHeapUsed = heapUsed;
}
if (recentUser > maxRecentUser) {
maxRecentUser = recentUser;
}
if (serviceCount > maxServiceCount) {
maxServiceCount = serviceCount;
}
if (apiTps > maxApiTps) {
maxApiTps = apiTps;
}
if (sqlTps > maxSqlTps) {
maxSqlTps = sqlTps;
}
if (tps > maxTps) {
maxTps = tps;
}
this.lastAccessTime = System.currentTimeMillis();
}
示例12: main
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static void main(String[] args) {
final JavaAgentStat jas = new JavaAgentStat(12345);
final long until = System.currentTimeMillis() + (60 * 60 * 1000);
new Thread() {
public void run() {
while (System.currentTimeMillis() < until) {
jas.addMax(5, 1024f, 80.5f, 10, 9, 8, 7, 6);
jas.addAvg(5, 80.5f, 10, 9, 8, 7, 6);
ThreadUtil.sleep(1000);
}
};
}.start();
long time = System.currentTimeMillis();
long last_sent = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
while (System.currentTimeMillis() < until) {
time = System.currentTimeMillis();
long now = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
if (now != last_sent) {
last_sent = now;
time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
System.err.println(new Date(time) + ":" + jas.getJavaAgentAndClear());
}
ThreadUtil.sleep(1000);
}
}
示例13: main
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static void main(String[] args) {
final HostAgentStat has = new HostAgentStat(12345);
final long until = System.currentTimeMillis() + (60 * 60 * 1000);
new Thread() {
public void run() {
while (System.currentTimeMillis() < until) {
has.addMax(90.7f, 16 * 1024 * 1024, 52.5f, 7 * 1024 * 1024, 10, 20, 30, 40);
has.addAvg(90.7f, 52.5f, 7 * 1024 * 1024);
ThreadUtil.sleep(1000);
}
};
}.start();
long time = System.currentTimeMillis();
long last_sent = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
while (System.currentTimeMillis() < until) {
time = System.currentTimeMillis();
long now = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
if (now != last_sent) {
last_sent = now;
time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
System.err.println(new Date(time) + ":" + has.getHostAgentAndClear());
}
ThreadUtil.sleep(1000);
}
}
示例14: getInstance
import scouter.util.ThreadUtil; //导入依赖的package包/类
public static synchronized RequestLogger getInstance() {
if (instance == null) {
instance = new RequestLogger();
instance.setDaemon(true);
instance.setName(ThreadUtil.getName(instance));
instance.start();
}
return instance;
}
示例15: run
import scouter.util.ThreadUtil; //导入依赖的package包/类
public void run() {
while (true) {
ThreadUtil.sleep(5000);
try {
File root = new File(Configure.getInstance().plugin_dir);
if (root != null && root.canRead()) {
checkModified(root);
checkNewRule(root);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}