public String getBlockSizeBytes() { if (mIsDirectory) { return ""; } else { return FormatUtils.getSizeFromBytes(mBlockSizeBytes); } }
public BlockMaster(Journal journal) { super(journal, Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("block-master-%d", true))); }
/** * @return Generated {@link WorkerInfo} for this worker */ public synchronized WorkerInfo generateClientWorkerInfo() { WorkerInfo ret = new WorkerInfo(); ret.id = mId; ret.address = mWorkerAddress; ret.lastContactSec = (int) ((CommonUtils.getCurrentMs() - mLastUpdatedTimeMs) / Constants.SECOND_MS); ret.state = "In Service"; ret.capacityBytes = mCapacityBytes; ret.usedBytes = mUsedBytes; ret.startTimeMs = mStartTimeMs; return ret; }
public static void main(String[] args) throws Exception { LocalTachyonCluster cluster = new LocalTachyonCluster(100, 8 * Constants.MB, Constants.GB); cluster.start(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster.stop(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster = new LocalTachyonCluster(100, 8 * Constants.MB, Constants.GB); cluster.start(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster.stop(); CommonUtils.sleepMs(Constants.SECOND_MS); }
private void writeFile(long fileId) throws IOException { ByteBuffer buf = ByteBuffer.allocate(mNumbers * 4); buf.order(ByteOrder.nativeOrder()); for (int k = 0; k < mNumbers; k ++) { buf.putInt(k); } buf.flip(); LOG.debug("Writing data..."); buf.flip(); long startTimeMs = CommonUtils.getCurrentMs(); FileOutStream os = new FileOutStream(fileId, mWriteOptions); os.write(buf.array()); os.close(); LOG.info(FormatUtils.formatTimeTakenMs(startTimeMs, "writeFile to file " + mFilePath)); }
public static DataServer createDataServer(final InetSocketAddress dataAddress, final BlockDataManager blockDataManager, TachyonConf conf) { try { return CommonUtils.createNewClassInstance( conf.<DataServer>getClass(Constants.WORKER_DATA_SERVER), new Class[] { InetSocketAddress.class, BlockDataManager.class, TachyonConf.class }, new Object[] { dataAddress, blockDataManager, conf }); } catch (Exception e) { throw Throwables.propagate(e); } } }
public static void main(String[] args) throws Exception { LocalTachyonCluster cluster = new LocalTachyonCluster(100, 8 * Constants.MB, Constants.GB); cluster.start(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster.stop(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster = new LocalTachyonCluster(100, 8 * Constants.MB, Constants.GB); cluster.start(); CommonUtils.sleepMs(Constants.SECOND_MS); cluster.stop(); CommonUtils.sleepMs(Constants.SECOND_MS); }
public String getSize() { if (mIsDirectory) { return ""; } else { return FormatUtils.getSizeFromBytes(mSize); } }
public static void createFiles() throws TachyonException, IOException { final long startTimeMs = CommonUtils.getCurrentMs(); for (int k = 0; k < sFiles; k ++) { TachyonFile file = sTFS.create(new TachyonURI(sFileName + (k + sBaseFileNumber))); long fileId = file.getFileId(); LOG.info( FormatUtils.formatTimeTakenMs(startTimeMs, "user_createFiles with fileId " + fileId)); } }
/** * @param conf TachyonConf to get the type of {@link JournalFormatter} * @return the created formatter */ public static JournalFormatter createJournalFormatter(TachyonConf conf) { try { return CommonUtils.createNewClassInstance( conf.<JournalFormatter>getClass(Constants.MASTER_JOURNAL_FORMATTER_CLASS), null, null); } catch (Exception e) { throw Throwables.propagate(e); } } }
public String getCapacity() { return FormatUtils.getSizeFromBytes(mCapacityBytes); }
private long createFile(TachyonFileSystem tachyonFileSystem) throws IOException, TachyonException { LOG.debug("Creating file..."); long startTimeMs = CommonUtils.getCurrentMs(); CreateOptions createOptions = (new CreateOptions.Builder(ClientContext.getConf())) .setBlockSizeBytes(mWriteOptions.getBlockSizeBytes()).setRecursive(true) .setTTL(mWriteOptions.getTTL()) .setUnderStorageType(mWriteOptions.getUnderStorageType()).build(); TachyonFile tFile = tachyonFileSystem.create(mFilePath, createOptions); long fileId = tFile.getFileId(); LOG.info(FormatUtils.formatTimeTakenMs(startTimeMs, "createFile with fileId " + fileId)); return fileId; }
/** * @param conf Tachyon configuration * @return a new instance of <code>RemoteBlockReader</code> */ public static RemoteBlockReader createRemoteBlockReader(TachyonConf conf) { try { return CommonUtils.createNewClassInstance( conf.<RemoteBlockReader>getClass(Constants.USER_BLOCK_REMOTE_READER), null, null); } catch (Exception e) { throw Throwables.propagate(e); } } }
public String getFreeCapacity() { return FormatUtils.getSizeFromBytes(mFreeBytes); }
/** * @param conf TachyonConf to determine the scheduler type * @return the generated scheduler */ public static CheckpointScheduler createScheduler(TachyonConf conf, LineageStoreView store) { try { return CommonUtils.createNewClassInstance( conf.<CheckpointScheduler>getClass(Constants.MASTER_LINEAGE_CHECKPOINT_CLASS), new Class[] {LineageStoreView.class}, new Object[] {store}); } catch (Exception e) { throw Throwables.propagate(e); } } }
public String getUsedCapacity() { return FormatUtils.getSizeFromBytes(mUsedBytes); }
/** * Creates a new <code>RemoteBlockWriter</code>. * * @param conf Tachyon configuration * @return a new instance of <code>RemoteBlockWriter</code> */ public static RemoteBlockWriter createRemoteBlockWriter(TachyonConf conf) { try { return CommonUtils.createNewClassInstance( conf.<RemoteBlockWriter>getClass(Constants.USER_BLOCK_REMOTE_WRITER), null, null); } catch (Exception e) { throw Throwables.propagate(e); } } }
public String getCapacity() { return FormatUtils.getSizeFromBytes(mCapacityBytes); }
/** * @param conf TachyonConf to determine the evictor type * @param view BlockMetadataManagerView to pass to Evictor * @param allocator an allocation policy * @return the generated Evictor */ public static Evictor createEvictor(TachyonConf conf, BlockMetadataManagerView view, Allocator allocator) { try { return CommonUtils.createNewClassInstance( conf.<Evictor>getClass(Constants.WORKER_EVICTOR_CLASS), new Class[]{BlockMetadataManagerView.class, Allocator.class}, new Object[]{view, allocator}); } catch (Exception e) { throw Throwables.propagate(e); } } }
public String getUsedMemory() { return FormatUtils.getSizeFromBytes(mUsedBytes); }