@Override public ClientPutter insert(InsertBlock insert, String filenameHint, boolean isMetadata, InsertContext ctx, ClientPutCallback cb, short priority) throws InsertException { ClientPutter put = new ClientPutter(cb, insert.getData(), insert.desiredURI, insert.clientMetadata, ctx, priority, isMetadata, filenameHint, false, core.clientContext, null, -1); try { core.clientContext.start(put); } catch (PersistenceDisabledException e) { // Impossible } return put; }
/** Called when we know exactly how many blocks will be needed. */ @Override public void onBlockSetFinished(ClientPutState state, ClientContext context) { if(logMINOR) Logger.minor(this, "Set finished", new Exception("debug")); blockSetFinalized(context); }
@Override public boolean canRestart() { if(!finished) { Logger.minor(this, "Cannot restart because not finished for "+identifier); return false; } if(succeeded) { Logger.minor(this, "Cannot restart because succeeded for "+identifier); return false; } return putter.canRestart(); }
private void fail(InsertException e, boolean fatal, ClientContext context) { synchronized(BinaryBlobInserter.this) { if(inserters[blockNum] == null) return; inserters[blockNum] = null; completedBlocks++; if(fatal) BinaryBlobInserter.this.fatal = true; } if(fatal) parent.fatallyFailedBlock(context); else parent.failedBlock(context); maybeFinish(context); }
boolean randomiseSplitfileKeys = randomiseSplitfileKeys(targetURI, ctx, persistent()); synchronized(this) { if(restart) { clearCountersOnRestart(); if(currentState != null && !finished) { if(logMINOR) Logger.minor(this, "Can't restart, not finished and currentState != null : "+currentState); if(!binaryBlob) { ClientMetadata meta = cm; if(meta != null) meta = persistent() ? meta.clone() : meta; currentState = new SingleFileInserter(this, this, new InsertBlock(data, meta, targetURI), isMetadata, ctx, realTimeFlag, false, false, null, null, false, targetFilename, false, persistent(), 0, 0, null, cryptoAlgorithm, cryptoKey, metadataThreshold); } else currentState = new BinaryBlobInserter(data, this, getClient(), false, priorityClass, ctx, context); onFailure(new InsertException(InsertExceptionMode.CANCELLED), null, context); return false; onFailure(new InsertException(InsertExceptionMode.CANCELLED), null, context); return false; onFailure(new InsertException(InsertExceptionMode.CANCELLED), null, context); return false;
BinaryBlobInserter(Bucket blob, ClientPutter parent, RequestClient clientContext, boolean tolerant, short prioClass, InsertContext ctx, ClientContext context) throws IOException, BinaryBlobFormatException { logMINOR = Logger.shouldLog(LogLevel.MINOR, this); this.ctx = ctx; this.maxRetries = ctx.maxInsertRetries; this.consecutiveRNFsCountAsSuccess = ctx.consecutiveRNFsCountAsSuccess; this.parent = parent; this.clientContext = clientContext; this.errors = new FailureCodeTracker(true); this.realTimeFlag = clientContext.realTimeFlag(); DataInputStream dis = new DataInputStream(blob.getInputStream()); BlockSet blocks = new SimpleBlockSet(); try { BinaryBlob.readBinaryBlob(dis, blocks, tolerant); } finally { dis.close(); } ArrayList<MySendableInsert> myInserters = new ArrayList<MySendableInsert>(); int x=0; for(Key key: blocks.keys()) { KeyBlock block = blocks.get(key); MySendableInsert inserter = new MySendableInsert(x++, block, prioClass, getScheduler(block, context), clientContext); myInserters.add(inserter); } inserters = myInserters.toArray(new MySendableInsert[myInserters.size()]); parent.addMustSucceedBlocks(inserters.length); parent.notifyClients(context); }
@Override public void onSuccess(SendableRequestItem keyNum, ClientKey key, ClientContext context) { synchronized(this) { if(inserters[blockNum] == null) return; inserters[blockNum] = null; completedBlocks++; succeededBlocks++; } parent.completedBlock(false, context); maybeFinish(context); }
/** * Cancels the running insert. */ @SuppressWarnings("synthetic-access") public void cancel() { clientPutter.cancel(node.clientCore.clientContext); eventBus.post(new ImageInsertAbortedEvent(image)); bucket.free(); }
public FreenetURI insert(InsertBlock insert, String filenameHint, boolean isMetadata, short priority, InsertContext ctx, byte[] forceCryptoKey) throws InsertException { PutWaiter pw = new PutWaiter(this); ClientPutter put = new ClientPutter(pw, insert.getData(), insert.desiredURI, insert.clientMetadata, ctx, priority, isMetadata, filenameHint, false, core.clientContext, forceCryptoKey, -1); try { core.clientContext.start(put); } catch (PersistenceDisabledException e) { // Impossible } return pw.waitForCompletion(); }
ClientPutter putter = new ClientPutter(callback, bucket, FreenetURI.EMPTY_CHK_URI, null, ctx, priority, false, null, true, updateManager.node.clientCore.clientContext, null, -1);
this.clientMetadata = cm; putter = new ClientPutter(this, data, this.uri, cm, ctx, priorityClass, isMetadata,
putter = new ClientPutter(this, data, this.uri, cm, ctx, priorityClass, isMetadata,
inserter = new ClientPutter(this, b, uri,