private static void waitFor(Callable<?> task) throws DhtException { try { task.call(); } catch (DhtException err) { throw err; } catch (Exception err) { throw new DhtException(err); } }
/** * @param message * @param cause */ public DhtException(String message, Throwable cause) { super(message); initCause(cause); }
private static void waitFor(Callable<?> task) throws DhtException { try { task.call(); } catch (DhtException err) { throw err; } catch (Exception err) { throw new DhtException(err); } }
/** * @param message * @param cause */ public DhtException(String message, Throwable cause) { super(message); initCause(cause); }
private static DhtException panicCannotInsert() { // This exception should never happen. return new DhtException(DhtText.get().cannotInsertObject); }
/** * @param cause */ public DhtException(Throwable cause) { super(cause.getMessage()); initCause(cause); }
private static DhtException panicCannotInsert() { // This exception should never happen. return new DhtException(DhtText.get().cannotInsertObject); }
/** * @param cause */ public DhtException(Throwable cause) { super(cause.getMessage()); initCause(cause); }
private static void waitFor(Future<?> task) throws DhtException { try { task.get(); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (ExecutionException err) { Throwable t = err; while (t != null) { if (t instanceof DhtException) throw (DhtException) t; t = t.getCause(); } throw new DhtException(err); } }
private static void waitFor(Future<?> task) throws DhtException { try { task.get(); } catch (InterruptedException e) { throw new DhtTimeoutException(e); } catch (ExecutionException err) { Throwable t = err; while (t != null) { if (t instanceof DhtException) throw (DhtException) t; t = t.getCause(); } throw new DhtException(err); } }
private ChunkKey chunkOf(long objectPtr) throws DhtException { List<ChunkKey> list = chunkByOrder[typeOf(objectPtr)]; int idx = chunkIdx(objectPtr); if (list == null || list.size() <= idx) { throw new DhtException(MessageFormat.format( DhtText.get().packParserInvalidPointer, // Constants.typeString(typeOf(objectPtr)), // Integer.valueOf(idx), // Integer.valueOf(offsetOf(objectPtr)))); } return list.get(idx); }
private int findStreamIndex(long streamPosition) throws DhtException { int high = objStreamPos.size(); int low = 0; do { final int mid = (low + high) >>> 1; final long pos = objStreamPos.get(mid); if (streamPosition < pos) high = mid; else if (streamPosition == pos) return mid; else low = mid + 1; } while (low < high); throw new DhtException(MessageFormat.format( DhtText.get().noSavedTypeForBase, Long.valueOf(streamPosition))); }
private int findStreamIndex(long streamPosition) throws DhtException { int high = objStreamPos.size(); int low = 0; do { final int mid = (low + high) >>> 1; final long pos = objStreamPos.get(mid); if (streamPosition < pos) high = mid; else if (streamPosition == pos) return mid; else low = mid + 1; } while (low < high); throw new DhtException(MessageFormat.format( DhtText.get().noSavedTypeForBase, Long.valueOf(streamPosition))); }
@Override protected void onPackHeader(long objCnt) throws IOException { if (Integer.MAX_VALUE < objCnt) { throw new DhtException(MessageFormat.format( DhtText.get().tooManyObjectsInPack, Long.valueOf(objCnt))); } objStreamPos = new LongList((int) objCnt); objChunkPtrs = new LongList((int) objCnt); if (saveAsCachedPack == null) setSaveAsCachedPack(1000 < objCnt); }
@Override protected void onPackHeader(long objCnt) throws IOException { if (Integer.MAX_VALUE < objCnt) { throw new DhtException(MessageFormat.format( DhtText.get().tooManyObjectsInPack, Long.valueOf(objCnt))); } objStreamPos = new LongList((int) objCnt); objChunkPtrs = new LongList((int) objCnt); if (saveAsCachedPack == null) setSaveAsCachedPack(1000 < objCnt); }
private ChunkKey chunkOf(long objectPtr) throws DhtException { List<ChunkKey> list = chunkByOrder[typeOf(objectPtr)]; int idx = chunkIdx(objectPtr); if (list == null || list.size() <= idx) { throw new DhtException(MessageFormat.format( DhtText.get().packParserInvalidPointer, // Constants.typeString(typeOf(objectPtr)), // Integer.valueOf(idx), // Integer.valueOf(offsetOf(objectPtr)))); } return list.get(idx); }
private ChunkFormatter openChunk(int typeCode) throws DhtException { if (typeCode == 0) throw new DhtException("Invalid internal typeCode 0"); ChunkFormatter w = openChunks[typeCode]; if (w == null) { w = new ChunkFormatter(repo, options); w.setSource(GitStore.ChunkInfo.Source.RECEIVE); w.setObjectType(typeCode); openChunks[typeCode] = w; } return w; }
private ChunkFormatter openChunk(int typeCode) throws DhtException { if (typeCode == 0) throw new DhtException("Invalid internal typeCode 0"); ChunkFormatter w = openChunks[typeCode]; if (w == null) { w = new ChunkFormatter(repo, options); w.setSource(GitStore.ChunkInfo.Source.RECEIVE); w.setObjectType(typeCode); openChunks[typeCode] = w; } return w; }
static ChunkIndex fromBytes(ChunkKey key, byte[] index, int ptr, int len) throws DhtException { int v = index[ptr] & 0xff; switch (v) { case V1: { final int offsetFormat = index[ptr + 1] & 7; switch (offsetFormat) { case 1: return new Offset1(index, ptr, len, key); case 2: return new Offset2(index, ptr, len, key); case 3: return new Offset3(index, ptr, len, key); case 4: return new Offset4(index, ptr, len, key); default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(NB.decodeUInt16(index, ptr)), key)); } } default: throw new DhtException(MessageFormat.format( DhtText.get().unsupportedChunkIndex, Integer.toHexString(v), key)); } }
throw new DhtException(MessageFormat.format( DhtText.get().missingLongOffsetBase, chunkKey, Long.valueOf(position)));