Mercurial > hg > Members > tatsuki > Alice
changeset 71:a3a2605e16a2
change checking debug mode of logger
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Feb 2012 21:10:15 +0900 |
parents | f2d4a4686036 |
children | 728c254347a6 |
files | src/alice/codesegment/CodeSegmentManager.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/RemoteDataSegmentManager.java src/alice/test/codesegment/local/StartCodeSegment.java src/alice/test/codesegment/local/TestCodeSegment.java |
diffstat | 6 files changed, 16 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/CodeSegmentManager.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/codesegment/CodeSegmentManager.java Tue Feb 21 21:10:15 2012 +0900 @@ -15,10 +15,8 @@ Integer.MAX_VALUE, // keepAliveTime TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); - private Logger log = Logger.getLogger(CodeSegmentManager.class); + private Logger logger = Logger.getLogger(CodeSegmentManager.class); - private boolean debug = false; - public static CodeSegmentManager get() { return instance; } @@ -26,8 +24,8 @@ public static void submit(CodeSegment cs) { CodeSegmentManager csManager = CodeSegmentManager.get(); csManager.codeSegmentExecutor.execute(cs); - if (csManager.debug) { - csManager.log.debug(cs.getClass().getName()); + if (csManager.logger.isDebugEnabled()) { + csManager.logger.debug(cs.getClass().getName()); } }
--- a/src/alice/datasegment/DataSegmentManager.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Tue Feb 21 21:10:15 2012 +0900 @@ -14,7 +14,6 @@ protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>(); protected LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>(); protected AtomicInteger seq = new AtomicInteger(1); - boolean debug = false; protected Runnable replyThread = new Runnable() { Logger logger = Logger.getLogger("reply"); @@ -30,7 +29,7 @@ } seqHash.remove(reply.seq); cmd.cs.ids.reply(cmd.receiver, new DataSegmentValue(reply.index, reply.val, reply.reverseKey)); - if (debug) + if (logger.isDebugEnabled()) logger.debug(reply.getCommandString() + " " + cmd.getCommandString()); } catch (InterruptedException e) { e.printStackTrace();
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 21 21:10:15 2012 +0900 @@ -14,7 +14,6 @@ private ConcurrentHashMap<String, DataSegmentKey> dataSegments = new ConcurrentHashMap<String, DataSegmentKey>(); private LinkedBlockingQueue<KeyCommand> cmdQueue = new LinkedBlockingQueue<KeyCommand>(); private Logger logger = Logger.getLogger("local"); - private boolean debug = false; private Runnable keyCommandThread = new Runnable() { @@ -33,7 +32,6 @@ }; - public LocalDataSegmentManager() { new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start(); new Thread(keyCommandThread, "LocalDataSegmentManager-runKeyCommand").start(); @@ -66,7 +64,7 @@ DataSegmentKey dataSegmentKey = getDataSegmentKey(key); Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, replyQueue, cs, reverseKey); addCommand(dataSegmentKey, cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -78,7 +76,7 @@ DataSegmentKey dataSegmentKey = getDataSegmentKey(key); Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, replyQueue, cs, reverseKey); addCommand(dataSegmentKey, cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -89,7 +87,7 @@ Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); addCommand(dataSegmentKey, cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -100,7 +98,7 @@ Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); // waiting for PUT or UPDATE at unique sequence number addCommand(dataSegmentKey, cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -109,7 +107,7 @@ DataSegmentKey dataSegmentKey = getDataSegmentKey(key); Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, replyQueue, null, null); addCommand(dataSegmentKey, cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); }
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Tue Feb 21 21:10:15 2012 +0900 @@ -16,7 +16,6 @@ Connection connection; Logger logger; - boolean debug = false; public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port) { logger = Logger.getLogger(connectionKey); @@ -54,7 +53,7 @@ public void put(String key, Value val, CodeSegment cs) { Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, cs, null); connection.sendCommand(cmd); // put command on the transmission thread - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -62,7 +61,7 @@ public void update(String key, Value val, CodeSegment cs) { Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, cs, null); connection.sendCommand(cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -72,7 +71,7 @@ Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); connection.sendCommand(cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -82,7 +81,7 @@ Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null); seqHash.put(seq, cmd); connection.sendCommand(cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); } @@ -90,7 +89,7 @@ public void remove(String key) { Command cmd = new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null, null); connection.sendCommand(cmd); - if (debug) + if (logger.isDebugEnabled()) logger.debug(cmd.getCommandString()); }
--- a/src/alice/test/codesegment/local/StartCodeSegment.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/test/codesegment/local/StartCodeSegment.java Tue Feb 21 21:10:15 2012 +0900 @@ -9,7 +9,7 @@ System.out.println("run StartCodeSegment"); TestCodeSegment cs = new TestCodeSegment(); - cs.arg1.setKey("local", "key1"); // unbound datasegment key1 is created and connect to cs. + cs.arg1.setKey("key1"); // unbound datasegment key1 is created and connect to cs. // cs is waiting for local.key1 System.out.println("create TestCodeSegment");
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Tue Feb 21 20:09:18 2012 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Tue Feb 21 21:10:15 2012 +0900 @@ -21,7 +21,7 @@ } TestCodeSegment cs = new TestCodeSegment(); - cs.arg1.setKey("local", "key1", arg1.index); + cs.arg1.setKey("key1", arg1.index); // DataSegment.get("local").update ods.update("local", "key1", "String data");