Package freenet.node

Examples of freenet.node.LowLevelPutException


                });
                if(request.localRequestOnly) {
                    try {
                        node.node.store(block, false, request.canWriteClientCache, true, false);
                    } catch (KeyCollisionException e) {
                        throw new LowLevelPutException(LowLevelPutException.COLLISION);
                    }
                } else {
                    node.realPut(block, request.canWriteClientCache, request.forkOnCacheable, Node.PREFER_INSERT_DEFAULT, Node.IGNORE_LOW_BACKOFF_DEFAULT, request.realTimeFlag);
                }
                request.onInsertSuccess(key, context);
                return true;
            } catch (final LowLevelPutException e) {
                request.onFailure(e, context);
                return true;
            } catch (final IOException e) {
                context.getJobRunner(request.isPersistent()).queueNormalOrDrop(new PersistentJob() {
                   
                    @Override
                    public boolean run(ClientContext context) {
                        try {
                            storage.failOnDiskError(e);
                        } finally {
                            // Must terminate the request anyway.
                            request.onFailure(new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, "Disk error", e), context);
                        }
                        return true;
                    }
                });
                return true;
            } catch (Throwable t) {
                Logger.error(this, "Failed to send insert: "+t, t);
                // We still need to terminate the insert.
                request.onFailure(new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, "Failed: "+t, t), context);
                return true;
            }
        }
View Full Code Here


      try {
        try {
          encodedBlock = innerEncode(context.random, block.uri, block.copyBucket, block.isMetadata, block.compressionCodec, block.sourceLength, compressorDescriptor, block.pre1254, block.cryptoAlgorithm, block.cryptoKey);
          b = encodedBlock.getBlock();
        } catch (CHKEncodeException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        } catch (SSKEncodeException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        } catch (MalformedURLException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        } catch (InsertException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        } catch (IOException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        } catch (InvalidCompressionCodecException e) {
          throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, e.toString() + ":" + e.getMessage(), e);
        }
        if (b==null) {
          Logger.error(this, "Asked to send empty block", new Exception("error"));
          return false;
        }
        key = encodedBlock.getClientKey();
        k = key;
        context.getJobRunner(block.persistent).queueNormalOrDrop(new PersistentJob() {
           
            @Override
            public boolean run(ClientContext context) {
                orig.onEncode(key, context);
                return true;
            }
           
        });
        if(req.localRequestOnly)
          try {
            core.node.store(b, false, req.canWriteClientCache, true, false);
          } 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?!");
              // Could be a race condition.
              try {
                core.node.store(b, false, req.canWriteClientCache, true, false);
              } catch (KeyCollisionException e2) {
                Logger.error(this, "Collided but no key and still collided!");
                throw new LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, "Collided, can't find block, but still collides!", e);
              }
            }
           
            failed.setCollidedBlock(collided);
            throw failed;
          }
        else
          core.realPut(b, req.canWriteClientCache, req.forkOnCacheable, Node.PREFER_INSERT_DEFAULT, Node.IGNORE_LOW_BACKOFF_DEFAULT, req.realTimeFlag);
      } catch (LowLevelPutException e) {
View Full Code Here

TOP

Related Classes of freenet.node.LowLevelPutException

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.