private static void waitFor(Callable<?> task) throws DhtException { try { task.call(); } catch (DhtException err) { throw err; } catch (Exception err) { throw new DhtException(err); } }
private static void waitFor(Callable<?> task) throws DhtException { try { task.call(); } catch (DhtException err) { throw err; } catch (Exception err) { throw new DhtException(err); } }
private static DhtException panicCannotInsert() { // This exception should never happen. return new DhtException(DhtText.get().cannotInsertObject); }
private static DhtException panicCannotInsert() { // This exception should never happen. return new DhtException(DhtText.get().cannotInsertObject); }
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); }
@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; }
public Collection<CachedPackInfo> getCachedPacks(RepositoryKey repo) throws DhtException, TimeoutException { List<CachedPackInfo> out = new ArrayList<CachedPackInfo>(4); for (MemTable.Cell cell : table.scanFamily(repo.asBytes(), colCachedPack)) { try { out.add(CachedPackInfo.parseFrom(cell.getValue())); } catch (InvalidProtocolBufferException e) { throw new DhtException(MessageFormat.format( DhtText.get().invalidCachedPackInfo, repo, CachedPackKey.fromBytes(cell.getName())), e); } } return out; }
public Map<RefKey, RefData> getAll(Context options, RepositoryKey repository) throws DhtException, TimeoutException { Map<RefKey, RefData> out = new HashMap<RefKey, RefData>(); for (MemTable.Cell cell : table.scanFamily(repository.asBytes(), colRef)) { RefKey ref = RefKey.fromBytes(colRef.suffix(cell.getName())); try { out.put(ref, RefData.parseFrom(cell.getValue())); } catch (InvalidProtocolBufferException badCell) { throw new DhtException(MessageFormat.format( DhtText.get().invalidRefData, ref), badCell); } } return out; }
void copyEntireChunkAsIs(PackOutputStream out, DhtObjectToPack obj, boolean validate) throws IOException { if (validate && !isValid()) { if (obj != null) throw new CorruptObjectException(obj, MessageFormat.format( DhtText.get().corruptChunk, getChunkKey())); else throw new DhtException(MessageFormat.format( DhtText.get().corruptChunk, getChunkKey())); } // Do not copy the trailer onto the output stream. out.write(dataBuf, dataPtr, dataLen - TRAILER_SIZE); }
void copyEntireChunkAsIs(PackOutputStream out, DhtObjectToPack obj, boolean validate) throws IOException { if (validate && !isValid()) { if (obj != null) throw new CorruptObjectException(obj, MessageFormat.format( DhtText.get().corruptChunk, getChunkKey())); else throw new DhtException(MessageFormat.format( DhtText.get().corruptChunk, getChunkKey())); } // Do not copy the trailer onto the output stream. out.write(dataBuf, dataPtr, dataLen - TRAILER_SIZE); }
public void putUnique(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { boolean ok = table.compareAndSet( // name.asBytes(), // colId.name(), // null, // key.asBytes()); if (!ok) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); }
public Map<RefKey, RefData> getAll(Context options, RepositoryKey repository) throws DhtException, TimeoutException { Map<RefKey, RefData> out = new HashMap<RefKey, RefData>(); for (MemTable.Cell cell : table.scanFamily(repository.asBytes(), colRef)) { RefKey ref = RefKey.fromBytes(colRef.suffix(cell.getName())); try { out.put(ref, RefData.parseFrom(cell.getValue())); } catch (InvalidProtocolBufferException badCell) { throw new DhtException(MessageFormat.format( DhtText.get().invalidRefData, ref), badCell); } } return out; }
public void remove(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { boolean ok = table.compareAndSet( name.asBytes(), colId.name(), key.asBytes(), null); if (!ok) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); } }
public void putUnique(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { boolean ok = table.compareAndSet( // name.asBytes(), // colId.name(), // null, // key.asBytes()); if (!ok) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); }
public void remove(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { boolean ok = table.compareAndSet( name.asBytes(), colId.name(), key.asBytes(), null); if (!ok) throw new DhtException(MessageFormat.format( DhtText.get().repositoryAlreadyExists, name.asString())); } }