Mercurial > hg > Database > Alice
changeset 471:be0b61986ff7 dispose
checking having DataSegmentManger before get DataSegmentManager
author | sugi |
---|---|
date | Mon, 24 Nov 2014 22:57:40 +0900 |
parents | 780ae843cdac |
children | 116e0fde9233 |
files | src/main/java/alice/codesegment/InputDataSegment.java src/main/java/alice/codesegment/OutputDataSegment.java src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/daemon/IncomingUdpConnection.java src/main/java/alice/datasegment/RemoteDataSegmentManager.java src/main/java/alice/topology/manager/keeparive/CatchDisconnectEvent.java src/main/java/alice/topology/manager/keeparive/RespondPing.java src/main/java/alice/topology/manager/keeparive/TaskExecuter.java src/main/java/alice/topology/node/DeleteConnection.java |
diffstat | 9 files changed, 50 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/codesegment/InputDataSegment.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/codesegment/InputDataSegment.java Mon Nov 24 22:57:40 2014 +0900 @@ -33,8 +33,10 @@ if (receiver.managerKey==null){ DataSegment.getLocal().peek(receiver, cs, null); } else { - SendOption option = new SendOption(true, false); - DataSegment.get(receiver.managerKey).peek(receiver, cs, option); + if (DataSegment.contains(receiver.managerKey)) { + SendOption option = new SendOption(true, false); + DataSegment.get(receiver.managerKey).peek(receiver, cs, option); + } } } @@ -44,8 +46,10 @@ if (receiver.managerKey==null){ DataSegment.getLocal().peek(receiver, cs, null); } else { - SendOption option = new SendOption(false, false); - DataSegment.get(receiver.managerKey).peek(receiver, cs, option); + if (DataSegment.contains(receiver.managerKey)) { + SendOption option = new SendOption(false, false); + DataSegment.get(receiver.managerKey).peek(receiver, cs, option); + } } } @@ -54,8 +58,10 @@ if (receiver.managerKey==null){ DataSegment.getLocal().take(receiver, cs, null); } else { - SendOption option = new SendOption(true, false); - DataSegment.get(receiver.managerKey).take(receiver, cs, option); + if (DataSegment.contains(receiver.managerKey)) { + SendOption option = new SendOption(true, false); + DataSegment.get(receiver.managerKey).take(receiver, cs, option); + } } } @@ -64,14 +70,16 @@ if (receiver.managerKey==null){ DataSegment.getLocal().take(receiver, cs, null); } else { - SendOption option = new SendOption(false, false); - DataSegment.get(receiver.managerKey).take(receiver, cs, option); + if (DataSegment.contains(receiver.managerKey)) { + SendOption option = new SendOption(false, false); + DataSegment.get(receiver.managerKey).take(receiver, cs, option); + } } } public void reply(Receiver receiver, Command reply) { receiver.index = reply.index; - receiver.from = reply.reverseKey; + receiver.from = reply.reverseKey; receiver.setData(reply.rData); receive(); } @@ -96,7 +104,7 @@ /** * InputDataSegment factory * @param type PEEK or TAKE - * @return Receiver of DataSegment reply + * @return Receiver of DataSegment reply */ public Receiver create(CommandType type) { return new Receiver(this, type);
--- a/src/main/java/alice/codesegment/OutputDataSegment.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/codesegment/OutputDataSegment.java Mon Nov 24 22:57:40 2014 +0900 @@ -48,7 +48,7 @@ * for remote */ public void put(String managerKey, String key, ReceiveData rData) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); } else { @@ -57,7 +57,7 @@ } public void put(String managerKey, String key, Object val) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); @@ -67,7 +67,7 @@ } public void quickPut(String managerKey, String key, ReceiveData rData) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); } else { @@ -76,7 +76,7 @@ } public void quickPut(String managerKey, String key, Object val) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); @@ -86,7 +86,7 @@ } public void update(String managerKey, String key, ReceiveData rData) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); } else { @@ -95,7 +95,7 @@ } public void update(String managerKey, String key, Object val) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); @@ -105,7 +105,7 @@ } public void quickUpdate(String managerKey, String key, ReceiveData rData) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); } else { @@ -114,7 +114,7 @@ } public void quickUpdate(String managerKey, String key, Object val) { - if (!managerKey.equals("local")){ + if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); @@ -130,7 +130,8 @@ */ public void finish(String managerKey) { - DataSegment.get(managerKey).finish(); + if (DataSegment.contains(managerKey)) + DataSegment.get(managerKey).finish(); } /** @@ -140,7 +141,8 @@ */ public void close(String managerKey) { - DataSegment.get(managerKey).close(); + if (DataSegment.contains(managerKey)) + DataSegment.get(managerKey).close(); } /** @@ -151,7 +153,8 @@ * @param key */ public void ping(String managerKey, String returnKey) { - DataSegment.get(managerKey).ping(returnKey); + if (DataSegment.contains(managerKey)) + DataSegment.get(managerKey).ping(returnKey); } /** @@ -161,7 +164,8 @@ */ public void shutdown(String managerKey){ - DataSegment.get(managerKey).shutdown(); + if (DataSegment.contains(managerKey)) + DataSegment.get(managerKey).shutdown(); } public boolean compressFlag() {
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Nov 24 22:57:40 2014 +0900 @@ -80,7 +80,8 @@ cmd.cs.ids.reply(cmd.receiver, rCmd); break; case PING: - DataSegment.get(reverseKey).response(msg.key); + if (DataSegment.contains(reverseKey)) + DataSegment.get(reverseKey).response(msg.key); break; case RESPONSE: rData = new ReceiveData(new RespondData(reverseKey, System.currentTimeMillis()), false, false);
--- a/src/main/java/alice/daemon/IncomingUdpConnection.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/daemon/IncomingUdpConnection.java Mon Nov 24 22:57:40 2014 +0900 @@ -72,7 +72,8 @@ cmd.cs.ids.reply(cmd.receiver, rCmd); break; case PING: - DataSegment.get(reverseKey).response(msg.key); + if (DataSegment.contains(reverseKey)) + DataSegment.get(reverseKey).response(msg.key); break; case RESPONSE: rData = new ReceiveData(new RespondData(reverseKey, System.currentTimeMillis()), false, false);
--- a/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Nov 24 22:57:40 2014 +0900 @@ -154,14 +154,12 @@ queue.clear(); } - System.out.println(out.getState()); if (out != null && out.getState() != Thread.State.TERMINATED) { Command cmd = new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, ""); queue.add(cmd); // outboundTCP Thread will stop. out = null; } - System.out.println(in.getState()); if (in != null || in.getState() != Thread.State.TERMINATED) { in = null; }
--- a/src/main/java/alice/topology/manager/keeparive/CatchDisconnectEvent.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/CatchDisconnectEvent.java Mon Nov 24 22:57:40 2014 +0900 @@ -8,9 +8,7 @@ @Override public void run() { ConnectionInfo e = getConnectionInfo(); - System.out.println("----------------------------"); - System.out.println("disconnection IPAddr"+ e.addr); - System.out.println("disconnection port"+ e.port); - System.out.println("----------------------------"); + System.out.println("IPAddr "+ e.addr); + System.out.println("port "+ e.port); } }
--- a/src/main/java/alice/topology/manager/keeparive/RespondPing.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/RespondPing.java Mon Nov 24 22:57:40 2014 +0900 @@ -20,7 +20,8 @@ System.out.println(" Recieved time "+(d.time - pingedTime)); if (d.time - pingedTime > 60 * 1000){ // need check, this connection is alive. may be close - DataSegment.get(d.from).shutdown(); + if (DataSegment.contains(d.from)) + DataSegment.get(d.from).shutdown(); } else { // if nowTask close d.from's socket cancel. // if not remove close task in the Queue.
--- a/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Mon Nov 24 22:57:40 2014 +0900 @@ -61,8 +61,12 @@ new RespondPing(nowTask.getReturnKey()); } else if (nowTask.getType() == TaskType.CLOSE) { // no response from the Remote DataSegment. So close this connection. - DataSegment.get(nowTask.getManagerKey()).shutdown(); - System.out.println(nowTask.getManagerKey() +" IS SHOTDOWN"); + if (DataSegment.contains(nowTask.getManagerKey())) { + DataSegment.get(nowTask.getManagerKey()).shutdown(); + System.out.println(nowTask.getManagerKey() +" IS SHOTDOWN"); + } else { + System.out.println(nowTask.getManagerKey() +" IS ALREADY SHOTDOWN"); + } } else if (nowTask.getType() == TaskType.CREATE) { new CreateTask(); }
--- a/src/main/java/alice/topology/node/DeleteConnection.java Mon Nov 24 19:52:13 2014 +0900 +++ b/src/main/java/alice/topology/node/DeleteConnection.java Mon Nov 24 22:57:40 2014 +0900 @@ -23,8 +23,8 @@ if (list.contains(name)) list.remove(name); - - DataSegment.get(name).shutdown(); + if (DataSegment.contains(name)) + DataSegment.get(name).shutdown(); ods.put(info.key, list); }