Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.apache.hadoop.ozone.recon.spi.OzoneManagerServiceProvider;
import org.apache.hadoop.ozone.recon.tasks.OMDBUpdatesHandler;
import org.apache.hadoop.ozone.recon.tasks.OMUpdateEventBatch;
import org.apache.hadoop.ozone.recon.tasks.ReconOmTask;
import org.apache.hadoop.ozone.recon.tasks.ReconTaskController;
import org.apache.hadoop.ozone.recon.tasks.updater.ReconTaskStatusUpdater;
import org.apache.hadoop.ozone.recon.tasks.updater.ReconTaskStatusUpdaterManager;
Expand Down Expand Up @@ -267,6 +268,10 @@ public void start() {
ReconServerConfigKeys.RECON_OM_SNAPSHOT_TASK_INITIAL_DELAY,
OZONE_RECON_OM_SNAPSHOT_TASK_INITIAL_DELAY_DEFAULT),
TimeUnit.MILLISECONDS);
// Initialize recon om tasks for any first time initialization of resources.
reconTaskController.getRegisteredTasks()
.values()
.forEach(ReconOmTask::init);
startSyncDataFromOM(initialDelay);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* Manages records in the Deleted Table, updating counts and sizes of
Expand All @@ -45,23 +45,19 @@ public class DeletedKeysInsightHandler implements OmTableHandler {
@Override
public void handlePutEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap) {

String countKey = getTableCountKeyFromTable(tableName);
String unReplicatedSizeKey = getUnReplicatedSizeKeyFromTable(tableName);
String replicatedSizeKey = getReplicatedSizeKeyFromTable(tableName);
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap) {

if (event.getValue() != null) {
RepeatedOmKeyInfo repeatedOmKeyInfo =
(RepeatedOmKeyInfo) event.getValue();
objectCountMap.computeIfPresent(countKey,
objectCountMap.computeIfPresent(getTableCountKeyFromTable(tableName),
(k, count) -> count + repeatedOmKeyInfo.getOmKeyInfoList().size());
Pair<Long, Long> result = repeatedOmKeyInfo.getTotalSize();
unReplicatedSizeMap.computeIfPresent(unReplicatedSizeKey,
unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
(k, size) -> size + result.getLeft());
replicatedSizeMap.computeIfPresent(replicatedSizeKey,
replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
(k, size) -> size + result.getRight());
} else {
LOG.warn("Put event does not have the Key Info for {}.",
Expand All @@ -77,23 +73,19 @@ public void handlePutEvent(OMDBUpdateEvent<String, Object> event,
@Override
public void handleDeleteEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap) {

String countKey = getTableCountKeyFromTable(tableName);
String unReplicatedSizeKey = getUnReplicatedSizeKeyFromTable(tableName);
String replicatedSizeKey = getReplicatedSizeKeyFromTable(tableName);
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap) {

if (event.getValue() != null) {
RepeatedOmKeyInfo repeatedOmKeyInfo =
(RepeatedOmKeyInfo) event.getValue();
objectCountMap.computeIfPresent(countKey, (k, count) ->
objectCountMap.computeIfPresent(getTableCountKeyFromTable(tableName), (k, count) ->
count > 0 ? count - repeatedOmKeyInfo.getOmKeyInfoList().size() : 0L);
Pair<Long, Long> result = repeatedOmKeyInfo.getTotalSize();
unReplicatedSizeMap.computeIfPresent(unReplicatedSizeKey,
unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
(k, size) -> size > result.getLeft() ? size - result.getLeft() : 0L);
replicatedSizeMap.computeIfPresent(replicatedSizeKey,
replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
(k, size) -> size > result.getRight() ? size - result.getRight() :
0L);
} else {
Expand All @@ -109,9 +101,9 @@ public void handleDeleteEvent(OMDBUpdateEvent<String, Object> event,
@Override
public void handleUpdateEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap) {
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap) {
// The size of deleted keys cannot change hence no-op.
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,10 @@ protected void handlePutKeyEvent(OmKeyInfo keyInfo, Map<Long,
// as this is a new ID
nsSummary = new NSSummary();
}
int numOfFile = nsSummary.getNumOfFiles();
long sizeOfFile = nsSummary.getSizeOfFiles();
int[] fileBucket = nsSummary.getFileSizeBucket();
nsSummary.setNumOfFiles(numOfFile + 1);
long dataSize = keyInfo.getDataSize();
nsSummary.setSizeOfFiles(sizeOfFile + dataSize);
int binIndex = ReconUtils.getFileSizeBinIndex(dataSize);
nsSummary.setNumOfFiles(nsSummary.getNumOfFiles() + 1);
nsSummary.setSizeOfFiles(nsSummary.getSizeOfFiles() + keyInfo.getDataSize());
int binIndex = ReconUtils.getFileSizeBinIndex(keyInfo.getDataSize());

++fileBucket[binIndex];
nsSummary.setFileSizeBucket(fileBucket);
Expand Down Expand Up @@ -168,18 +165,15 @@ protected void handleDeleteKeyEvent(OmKeyInfo keyInfo,
LOG.error("The namespace table is not correctly populated.");
return;
}
int numOfFile = nsSummary.getNumOfFiles();
long sizeOfFile = nsSummary.getSizeOfFiles();
int[] fileBucket = nsSummary.getFileSizeBucket();

long dataSize = keyInfo.getDataSize();
int binIndex = ReconUtils.getFileSizeBinIndex(dataSize);
int binIndex = ReconUtils.getFileSizeBinIndex(keyInfo.getDataSize());

// decrement count, data size, and bucket count
// even if there's no direct key, we still keep the entry because
// we still need children dir IDs info
nsSummary.setNumOfFiles(numOfFile - 1);
nsSummary.setSizeOfFiles(sizeOfFile - dataSize);
nsSummary.setNumOfFiles(nsSummary.getNumOfFiles() - 1);
nsSummary.setSizeOfFiles(nsSummary.getSizeOfFiles() - keyInfo.getDataSize());
--fileBucket[binIndex];
nsSummary.setFileSizeBucket(fileBucket);
nsSummaryMap.put(parentObjectId, nsSummary);
Expand All @@ -189,7 +183,6 @@ protected void handleDeleteDirEvent(OmDirectoryInfo directoryInfo,
Map<Long, NSSummary> nsSummaryMap)
throws IOException {
long parentObjectId = directoryInfo.getParentObjectID();
long objectId = directoryInfo.getObjectID();
// Try to get the NSSummary from our local map that maps NSSummaries to IDs
NSSummary nsSummary = nsSummaryMap.get(parentObjectId);
if (nsSummary == null) {
Expand All @@ -203,7 +196,7 @@ protected void handleDeleteDirEvent(OmDirectoryInfo directoryInfo,
return;
}

nsSummary.removeChildDir(objectId);
nsSummary.removeChildDir(directoryInfo.getObjectID());
nsSummaryMap.put(parentObjectId, nsSummary);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.hadoop.hdds.utils.db.TableIterator;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* Interface for handling PUT, DELETE and UPDATE events for size-related
Expand All @@ -43,9 +43,9 @@ public interface OmTableHandler {
*/
void handlePutEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap);
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap);


/**
Expand All @@ -60,9 +60,9 @@ void handlePutEvent(OMDBUpdateEvent<String, Object> event,
*/
void handleDeleteEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap);
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap);


/**
Expand All @@ -77,9 +77,9 @@ void handleDeleteEvent(OMDBUpdateEvent<String, Object> event,
*/
void handleUpdateEvent(OMDBUpdateEvent<String, Object> event,
String tableName,
HashMap<String, Long> objectCountMap,
HashMap<String, Long> unReplicatedSizeMap,
HashMap<String, Long> replicatedSizeMap);
Map<String, Long> objectCountMap,
Map<String, Long> unReplicatedSizeMap,
Map<String, Long> replicatedSizeMap);


/**
Expand Down
Loading
Loading