/** * @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; }
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)); }
private boolean readFile(TachyonFileSystem tachyonFileSystem, long fileId) throws IOException, TachyonException { boolean pass = true; LOG.debug("Reading data..."); TachyonFile file = new TachyonFile(fileId); final long startTimeMs = CommonUtils.getCurrentMs(); FileInStream is = tachyonFileSystem.getInStream(file, mReadOptions); ByteBuffer buf = ByteBuffer.allocate((int) is.remaining()); is.read(buf.array()); buf.order(ByteOrder.nativeOrder()); for (int k = 0; k < mNumbers; k ++) { pass = pass && (buf.getInt() == k); } is.close(); LOG.info(FormatUtils.formatTimeTakenMs(startTimeMs, "readFile file " + mFilePath)); return pass; }
@Override public void heartbeat() { LOG.debug("System status checking."); TachyonConf conf = MasterContext.getConf(); int masterWorkerTimeoutMs = conf.getInt(Constants.MASTER_WORKER_TIMEOUT_MS); synchronized (mBlocks) { synchronized (mWorkers) { Iterator<MasterWorkerInfo> iter = mWorkers.iterator(); while (iter.hasNext()) { MasterWorkerInfo worker = iter.next(); final long lastUpdate = CommonUtils.getCurrentMs() - worker.getLastUpdatedTimeMs(); if (lastUpdate > masterWorkerTimeoutMs) { LOG.error("The worker {} got timed out!", worker); mLostWorkers.add(worker); iter.remove(); processLostWorker(worker); } } } } }
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)); } }
if (mInitiateShutdown) { if (waitForShutdownStart == -1) { waitForShutdownStart = CommonUtils.getCurrentMs(); } else if ((CommonUtils.getCurrentMs() - waitForShutdownStart) > mShutdownQuietWaitTimeMs) {
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; }