Skip to content

Commit

Permalink
Add block worker report and worker report.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinjia committed Jun 27, 2015
1 parent 267a4af commit fcc3582
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
39 changes: 39 additions & 0 deletions servers/src/main/java/tachyon/worker/BlockWorkerReport.java
@@ -0,0 +1,39 @@
package tachyon.worker;

import java.util.List;
import java.util.Map;

/**
* Represents the data the CoreWorker will send to the master in its periodic heartbeat.
*/
// TODO: Make this a thrift object?
public class BlockWorkerReport extends WorkerReport {
private final long mWorkerId;
private final List<Long> mUsedBytesOnTiers;
private final List<Long> mRemovedBlocks;
private final Map<Long, List<Long>> mAddedBlocks;

public BlockWorkerReport(long workerId, List<Long> usedBytesOnTiers, List<Long> removedBlocks,
Map<Long, List<Long>> addedBlocks) {
mWorkerId = workerId;
mUsedBytesOnTiers = usedBytesOnTiers;
mRemovedBlocks = removedBlocks;
mAddedBlocks = addedBlocks;
}

public Map<Long, List<Long>> getAddedBlocks() {
return mAddedBlocks;
}

public List<Long> getRemovedBlocks() {
return mRemovedBlocks;
}

public List<Long> getUsedBytesOnTiers() {
return mUsedBytesOnTiers;
}

public long getWorkerId() {
return mWorkerId;
}
}
4 changes: 2 additions & 2 deletions servers/src/main/java/tachyon/worker/TachyonWorker.java
Expand Up @@ -80,8 +80,8 @@ public void run() {
} }


try { try {
BlockReport blockReport = mCoreWorker.getBlockReport(); BlockWorkerReport blockReport = mCoreWorker.getReport();
cmd = mMasterClient.worker_heartbeat(mWorkerId, blockReport.getUsedBytes(), cmd = mMasterClient.worker_heartbeat(mWorkerId, blockReport.getUsedBytesOnTiers(),
blockReport.getRemovedBlocks(), blockReport.getAddedBlocks()); blockReport.getRemovedBlocks(), blockReport.getAddedBlocks());
lastHeartbeatMs = System.currentTimeMillis(); lastHeartbeatMs = System.currentTimeMillis();
} catch (IOException e) { } catch (IOException e) {
Expand Down
8 changes: 8 additions & 0 deletions servers/src/main/java/tachyon/worker/WorkerReport.java
@@ -0,0 +1,8 @@
package tachyon.worker;

/**
* Represents a report from the worker to the master. Each worker type should implement its own
* version of the report.
*/
public class WorkerReport {
}

0 comments on commit fcc3582

Please sign in to comment.