00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.ssh;
00032
00033
00042 public class TryCache {
00043 private java.util.Hashtable<String, Boolean> _hash;
00044
00045 public TryCache() {
00046 _hash = new java.util.Hashtable<String, Boolean>();
00047 }
00048
00049 private String getKey(String host, int port) {
00050 return host;
00051 }
00052
00053 public boolean everTried(String host, int port) {
00054 String key = getKey(host, port);
00055 Boolean bool = _hash.get(key);
00056 if (bool != null) {
00057
00058 return true;
00059 } else {
00060
00061 return false;
00062 }
00063 }
00064
00069 public boolean needToTry(String host, int port) {
00070 String key = getKey(host, port);
00071 Boolean bool = _hash.get(key);
00072 if (bool != null) {
00073 if (bool.booleanValue()) {
00074
00075 return true;
00076 } else {
00077
00078 return false;
00079 }
00080 } else {
00081
00082 return true;
00083 }
00084 }
00085
00086 public void recordTrySuccess(String host, int port) {
00087 String key = getKey(host, port);
00088 _hash.put(key, new Boolean(true));
00089 }
00090
00091 public void recordTryFailure(String host, int port) {
00092 String key = getKey(host, port);
00093 _hash.put(key, new Boolean(false));
00094 }
00095 }