@Override public Key[] listKeys() { synchronized(this) { if(cancelled || finished) return new Key[0]; } return new Key[] { key.getNodeKey(true) }; }
public Key getNodeKey() { return getNodeKey(true); }
@Override public Key getNodeKey(SendableRequestItem token) { ClientKey key = getKey(token); if(key == null) return null; return key.getNodeKey(true); }
@Override public ClientKeyBlock get(ClientKey key) { KeyBlock block = get(key.getNodeKey(false)); if(block == null) return null; try { return Key.createKeyBlock(key, block); } catch (KeyVerifyException e) { Logger.error(this, "Caught decoding block with "+key+" : "+e, e); return null; } }
@Override public KeyListener makeKeyListener(ClientContext context, boolean onStartup) { synchronized(this) { if(finished) return null; if(cancelled) return null; } if(key == null) { Logger.error(this, "Key is null - left over BSSF? on "+this+" in makeKeyListener()", new Exception("error")); return null; } Key newKey = key.getNodeKey(true); if(parent == null) { Logger.error(this, "Parent is null on "+this+" persistent="+persistent+" key="+key+" ctx="+ctx); return null; } short prio = parent.getPriorityClass(); KeyListener ret = new SingleKeyListener(newKey, this, prio, persistent); return ret; }
@Override public SendableRequestItem chooseKey(KeysFetchingLocally fetching, ClientContext context) { Key k = key.getNodeKey(false); if(fetching.hasKey(k, this)) return null; long l = fetching.checkRecentlyFailed(k, realTimeFlag); long now = System.currentTimeMillis(); if(l > 0 && l > now) { if(maxRetries == -1 || (maxRetries >= RequestScheduler.COOLDOWN_RETRIES)) { // FIXME synchronization!!! if(logMINOR) Logger.minor(this, "RecentlyFailed -> cooldown until "+TimeUtil.formatTime(l-now)+" on "+this); cooldownWakeupTime = Math.max(cooldownWakeupTime, l); return null; } else { this.onFailure(new LowLevelGetException(LowLevelGetException.RECENTLY_FAILED), null, context); return null; } } return keys[0]; }
public void onGotKey(Key key, KeyBlock block, ClientContext context) { synchronized(this) { if(finished) { if(logMINOR) Logger.minor(this, "onGotKey() called twice on "+this, new Exception("debug")); return; } finished = true; if(isCancelled()) return; if(key == null) throw new NullPointerException(); if(this.key == null) throw new NullPointerException("Key is null on "+this); if(!key.equals(this.key.getNodeKey(false))) { Logger.normal(this, "Got sent key "+key+" but want "+this.key+" for "+this); return; } } unregister(context, getPriorityClass()); // Key has already been removed from pendingKeys onSuccess(block, false, null, context); }
System.err.println("Created random test key "+testKey+" = "+fetchKey.getNodeKey(false)); System.err.println();
testKey = insertKey.getURI(); final Key nodeKey = fetchKey.getNodeKey(false); int count = 0; for(Node node: nodes) { if(node.hasKey(fetchKey.getNodeKey(false), true, true)) count++; System.err.print("Nodes that do have the data: "); for(int i=0;i<nodes.length;i++) if(nodes[i].hasKey(fetchKey.getNodeKey(false), true, true)) { System.err.print(i+" ");
final Key k = key.getNodeKey(); core.asyncGet(k, false, new RequestCompletionListener() {
} catch (KeyCollisionException e) { LowLevelPutException failed = new LowLevelPutException(LowLevelPutException.COLLISION); KeyBlock collided = core.node.fetch(k.getNodeKey(), true, req.canWriteClientCache, false, false, null); if(collided == null) { Logger.error(this, "Collided but no key?!");