Package freenet.client

Examples of freenet.client.InsertException


                r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0);
        storage.start();
        assertEquals(storage.getStatus(), Status.STARTED);
        assertEquals(storage.segments.length, 1);
        SplitFileInserterSegmentStorage segment = storage.segments[0];
        segment.onFailure(0, new InsertException(InsertExceptionMode.INTERNAL_ERROR));
        data.proceed(); // Now it will complete encoding, and then report in, and then fail.
        try {
            cb.waitForFinishedEncode();
            assertFalse(true); // Should have failed.
        } catch (InsertException e) {
View Full Code Here


            assertTrue(allCrossSegmentsEncoding(storage));
        else
            assertTrue(allSegmentsEncoding(storage));
        SplitFileInserterSegmentStorage segment = storage.segments[0];
        assertTrue(memoryLimitedJobRunner.getRunningThreads() > 0);
        segment.onFailure(0, new InsertException(InsertExceptionMode.INTERNAL_ERROR));
        try {
            Thread.sleep(100);
        } catch (InterruptedException e1) {
            // Ignore.
        }
View Full Code Here

            SplitFileInserterSegmentStorage segment = resumed.segments[0];
            assertEquals(segment.dataBlockCount, 2);
            assertEquals(segment.checkBlockCount, 3);
            assertEquals(segment.crossCheckBlockCount, 0);
            assertTrue(resumed.getStatus() == Status.ENCODED);
            segment.onFailure(0, new InsertException(InsertExceptionMode.ROUTE_NOT_FOUND));
        }
        try {
            cb.waitForSucceededInsert();
            assertTrue(false);
        } catch (InsertException e) {
View Full Code Here

            BlockInsert chosen = segment.chooseBlock();
            assertTrue(chosen != null);
            keys.addInsert(chosen);
            assertFalse(chosenBlocks[chosen.blockNumber]);
            chosenBlocks[chosen.blockNumber] = true;
            segment.onFailure(chosen.blockNumber, new InsertException(InsertExceptionMode.ROUTE_NOT_FOUND));
        }
        keys.clear();
        // Choose and succeed all blocks.
        chosenBlocks = new boolean[totalBlockCount];
        for(int i=0;i<totalBlockCount;i++) {
View Full Code Here

    boolean pre1254 = !(cmode == CompatibilityMode.COMPAT_CURRENT || cmode.ordinal() >= CompatibilityMode.COMPAT_1255.ordinal());
    try {
      return innerEncode(random, uri, sourceData, isMetadata, compressionCodec, sourceLength, ctx.compressorDescriptor, pre1254, cryptoAlgorithm, cryptoKey);
    } catch (KeyEncodeException e) {
      Logger.error(SingleBlockInserter.class, "Caught "+e, e);
      throw new InsertException(InsertExceptionMode.INTERNAL_ERROR, e, null);
    } catch (MalformedURLException e) {
      throw new InsertException(InsertExceptionMode.INVALID_URI, e, null);
    } catch (IOException e) {
      Logger.error(SingleBlockInserter.class, "Caught "+e+" encoding data "+sourceData, e);
      throw new InsertException(InsertExceptionMode.BUCKET_ERROR, e, null);
    } catch (InvalidCompressionCodecException e) {
      throw new InsertException(InsertExceptionMode.INTERNAL_ERROR, e, null);
    }
     
  }
View Full Code Here

      return ClientCHKBlock.encode(sourceData, isMetadata, compressionCodec == -1, compressionCodec, sourceLength, compressorDescriptor, pre1254, cryptoKey, cryptoAlgorithm);
    } else if(uriType.equals("SSK") || uriType.equals("KSK")) {
      InsertableClientSSK ik = InsertableClientSSK.create(uri);
      return ik.encode(sourceData, isMetadata, compressionCodec == -1, compressionCodec, sourceLength, random, compressorDescriptor, pre1254);
    } else {
      throw new InsertException(InsertExceptionMode.INVALID_URI, "Unknown keytype "+uriType, null);
    }
  }
View Full Code Here

  public void onFailure(LowLevelPutException e, SendableRequestItem keyNum, ClientContext context) {
    synchronized(this) {
      if(finished) return;
    }
    if(parent.isCancelled()) {
      fail(new InsertException(InsertExceptionMode.CANCELLED), context);
      return;
    }
    if(logMINOR) Logger.minor(this, "onFailure() on "+e+" for "+this);
   
    switch(e.code) {
    case LowLevelPutException.COLLISION:
      fail(new InsertException(InsertExceptionMode.COLLISION), context);
      return;
    case LowLevelPutException.INTERNAL_ERROR:
      fail(new InsertException(InsertExceptionMode.INTERNAL_ERROR), context);
      return;
    case LowLevelPutException.REJECTED_OVERLOAD:
      errors.inc(InsertExceptionMode.REJECTED_OVERLOAD);
      break;
    case LowLevelPutException.ROUTE_NOT_FOUND:
View Full Code Here

    } catch (InsertException e) {
      cb.onFailure(e, this, context);
      return null;
    } catch (Throwable t) {
      Logger.error(this, "Caught "+t, t);
      cb.onFailure(new InsertException(InsertExceptionMode.INTERNAL_ERROR, t, null), this, context);
      return null;
    }
  }
View Full Code Here

  @Override
  public void onSuccess(SendableRequestItem keyNum, ClientKey key, ClientContext context) {
      onEncode(key, context);
    if(logMINOR) Logger.minor(this, "Succeeded ("+this+"): "+token);
    if(parent.isCancelled()) {
      fail(new InsertException(InsertExceptionMode.CANCELLED), context);
      return;
    }
    boolean shouldSendKey = false;
    synchronized(this) {
      if(extraInserts > 0 && !ctx.getCHKOnly) {
View Full Code Here

    if(freeData) {
      sourceData.free();
      sourceData = null;
    }
    super.unregister(context, getPriorityClass());
    cb.onFailure(new InsertException(InsertExceptionMode.CANCELLED), this, context);
  }
View Full Code Here

TOP

Related Classes of freenet.client.InsertException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.