Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -39,6 +39,13 @@ public final class HddsPolicyProvider extends PolicyProvider {
private static final Supplier<HddsPolicyProvider> SUPPLIER =
MemoizedSupplier.valueOf(HddsPolicyProvider::new);

private static final List<Service> DN_SERVICES =
Collections.singletonList(
new Service(
OZONE_SECURITY_RECONFIGURE_PROTOCOL_ACL,
ReconfigureProtocol.class)
);

private HddsPolicyProvider() {
}

Expand All @@ -48,12 +55,6 @@ public static HddsPolicyProvider getInstance() {
return SUPPLIER.get();
}

private static final List<Service> DN_SERVICES =
Collections.singletonList(
new Service(
OZONE_SECURITY_RECONFIGURE_PROTOCOL_ACL,
ReconfigureProtocol.class)
);

@Override
public Service[] getServices() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,11 @@
*/
@InterfaceAudience.Private
public final class CommandHandlerMetrics implements MetricsSource {
enum CommandMetricsMetricsInfo implements MetricsInfo {
Command("The type of the SCM command"),
TotalRunTimeMs("The total runtime of the command handler in milliseconds"),
AvgRunTimeMs("Average run time of the command handler in milliseconds"),
QueueWaitingTaskCount("The number of queued tasks waiting for execution"),
InvocationCount("The number of times the command handler has been invoked"),
ThreadPoolActivePoolSize("The number of active threads in the thread pool"),
ThreadPoolMaxPoolSize("The maximum number of threads in the thread pool"),
CommandReceivedCount(
"The number of received SCM commands for each command type");

private final String desc;
CommandMetricsMetricsInfo(String desc) {
this.desc = desc;
}
public static final String SOURCE_NAME = CommandHandlerMetrics.class.getSimpleName();

@Override
public String description() {
return desc;
}
}

public static final String SOURCE_NAME =
CommandHandlerMetrics.class.getSimpleName();
private final Map<Type, CommandHandler> handlerMap;
private final Map<Type, AtomicInteger> commandCount;

private CommandHandlerMetrics(Map<Type, CommandHandler> handlerMap) {
this.handlerMap = handlerMap;
this.commandCount = new HashMap<>();
Expand Down Expand Up @@ -121,4 +100,26 @@ public void unRegister() {
MetricsSystem ms = DefaultMetricsSystem.instance();
ms.unregisterSource(SOURCE_NAME);
}

enum CommandMetricsMetricsInfo implements MetricsInfo {
Command("The type of the SCM command"),
TotalRunTimeMs("The total runtime of the command handler in milliseconds"),
AvgRunTimeMs("Average run time of the command handler in milliseconds"),
QueueWaitingTaskCount("The number of queued tasks waiting for execution"),
InvocationCount("The number of times the command handler has been invoked"),
ThreadPoolActivePoolSize("The number of active threads in the thread pool"),
ThreadPoolMaxPoolSize("The maximum number of threads in the thread pool"),
CommandReceivedCount(
"The number of received SCM commands for each command type");

private final String desc;
CommandMetricsMetricsInfo(String desc) {
this.desc = desc;
}

@Override
public String description() {
return desc;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
* marking the container as closed.
*/
public class OpenContainerBlockMap {
/**
* TODO : We may construct the openBlockMap by reading the Block Layout
* for each block inside a container listing all chunk files and reading the
* sizes. This will help to recreate the openKeys Map once the DataNode
* restarts.
*
* For now, we will track all open blocks of a container in the blockMap.
*/
private final ConcurrentMap<Long, BlockDataMap> containers = new ConcurrentHashMap<>();

/**
* Map: localId {@literal ->} BlockData.
*
Expand Down Expand Up @@ -69,17 +79,6 @@ synchronized List<BlockData> getAll() {
}
}

/**
* TODO : We may construct the openBlockMap by reading the Block Layout
* for each block inside a container listing all chunk files and reading the
* sizes. This will help to recreate the openKeys Map once the DataNode
* restarts.
*
* For now, we will track all open blocks of a container in the blockMap.
*/
private final ConcurrentMap<Long, BlockDataMap> containers =
new ConcurrentHashMap<>();

/**
* Removes the Container matching with specified containerId.
* @param containerId containerId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,6 @@ public interface Container<CONTAINERDATA extends ContainerData> {
* Encapsulates the result of a container scan.
*/
class ScanResult {
/**
* Represents the reason a container scan failed and a container should
* be marked unhealthy.
*/
public enum FailureType {
MISSING_CONTAINER_DIR,
MISSING_METADATA_DIR,
MISSING_CONTAINER_FILE,
MISSING_CHUNKS_DIR,
MISSING_CHUNK_FILE,
CORRUPT_CONTAINER_FILE,
CORRUPT_CHUNK,
INCONSISTENT_CHUNK_LENGTH,
INACCESSIBLE_DB,
WRITE_FAILURE,
DELETED_CONTAINER
}

private final boolean healthy;
private final File unhealthyFile;
private final FailureType failureType;
Expand Down Expand Up @@ -94,6 +76,24 @@ public FailureType getFailureType() {
public Throwable getException() {
return exception;
}

/**
* Represents the reason a container scan failed and a container should
* be marked unhealthy.
*/
public enum FailureType {
MISSING_CONTAINER_DIR,
MISSING_METADATA_DIR,
MISSING_CONTAINER_FILE,
MISSING_CHUNKS_DIR,
MISSING_CHUNK_FILE,
CORRUPT_CONTAINER_FILE,
CORRUPT_CHUNK,
INCONSISTENT_CHUNK_LENGTH,
INACCESSIBLE_DB,
WRITE_FAILURE,
DELETED_CONTAINER
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,7 @@ public class DatanodeConfiguration extends ReconfigurableConfig {
description = "Timeout for the thread used to process the delete" +
" block command to wait for the container lock."
)
private long blockDeleteMaxLockWaitTimeoutMs =
Duration.ofMillis(100).toMillis();

public Duration getBlockDeletionInterval() {
return blockDeletionInterval;
}

public void setRecoveringContainerScrubInterval(Duration duration) {
recoveringContainerScrubInterval = duration;
}

public Duration getRecoveringContainerScrubInterval() {
return recoveringContainerScrubInterval;
}

public void setBlockDeletionInterval(Duration duration) {
blockDeletionInterval = duration;
}
private long blockDeleteMaxLockWaitTimeoutMs = Duration.ofMillis(100).toMillis();

@Config(key = "block.deleting.limit.per.interval",
defaultValue = "5000",
Expand All @@ -306,10 +289,6 @@ public void setBlockDeletionInterval(Duration duration) {
)
private int blockLimitPerInterval = 5000;

public int getBlockDeletionLimit() {
return blockLimitPerInterval;
}

@Config(key = "block.deleting.max.lock.holding.time",
defaultValue = "1s",
type = ConfigType.TIME,
Expand All @@ -323,20 +302,7 @@ public int getBlockDeletionLimit() {
+ "which means the actual execution time may exceed this limit. "
+ "Unit could be defined with postfix (ns,ms,s,m,h,d). "
)
private long blockDeletingMaxLockHoldingTime =
Duration.ofSeconds(1).toMillis();

public Duration getBlockDeletingMaxLockHoldingTime() {
return Duration.ofMillis(blockDeletingMaxLockHoldingTime);
}

public void setBlockDeletingMaxLockHoldingTime(Duration maxLockHoldingTime) {
blockDeletingMaxLockHoldingTime = maxLockHoldingTime.toMillis();
}

public void setBlockDeletionLimit(int limit) {
this.blockLimitPerInterval = limit;
}
private long blockDeletingMaxLockHoldingTime = Duration.ofSeconds(1).toMillis();

@Config(key = "hdds.datanode.volume.min.free.space",
defaultValue = "-1",
Expand Down Expand Up @@ -484,14 +450,6 @@ public void setBlockDeletionLimit(int limit) {

private boolean waitOnAllFollowers = WAIT_ON_ALL_FOLLOWERS_DEFAULT;

public boolean waitOnAllFollowers() {
return waitOnAllFollowers;
}

public void setWaitOnAllFollowers(boolean val) {
this.waitOnAllFollowers = val;
}

@Config(key = "container.schema.v3.enabled",
defaultValue = "true",
type = ConfigType.BOOLEAN,
Expand Down Expand Up @@ -627,10 +585,50 @@ public void setWaitOnAllFollowers(boolean val) {
)
private long deleteContainerTimeoutMs = Duration.ofSeconds(60).toMillis();

public Duration getBlockDeletionInterval() {
return blockDeletionInterval;
}

public void setRecoveringContainerScrubInterval(Duration duration) {
recoveringContainerScrubInterval = duration;
}

public Duration getRecoveringContainerScrubInterval() {
return recoveringContainerScrubInterval;
}

public void setBlockDeletionInterval(Duration duration) {
blockDeletionInterval = duration;
}

public int getBlockDeletionLimit() {
return blockLimitPerInterval;
}

public long getDeleteContainerTimeoutMs() {
return deleteContainerTimeoutMs;
}

public Duration getBlockDeletingMaxLockHoldingTime() {
return Duration.ofMillis(blockDeletingMaxLockHoldingTime);
}

public void setBlockDeletingMaxLockHoldingTime(Duration maxLockHoldingTime) {
blockDeletingMaxLockHoldingTime = maxLockHoldingTime.toMillis();
}

public boolean waitOnAllFollowers() {
return waitOnAllFollowers;
}

public void setWaitOnAllFollowers(boolean val) {
this.waitOnAllFollowers = val;
}

public void setBlockDeletionLimit(int limit) {
this.blockLimitPerInterval = limit;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are already moving these, how about putting get/set pairs next to each other, in consistent order?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@PostConstruct
public void validate() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java
 548: Method validate length is 159 lines (max allowed is 150).

Can we defer improvements in validate() to a separate task?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, was overoptimistic with chages. Reverted

if (containerDeleteThreads < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,36 @@
* Then, WriteChunk commit and CreateContainer will be executed in the same order.
*/
public class ContainerStateMachine extends BaseStateMachine {
static final Logger LOG =
LoggerFactory.getLogger(ContainerStateMachine.class);
static final Logger LOG = LoggerFactory.getLogger(ContainerStateMachine.class);

private final SimpleStateMachineStorage storage = new SimpleStateMachineStorage();
private final ContainerDispatcher dispatcher;
private final ContainerController containerController;
private final XceiverServerRatis ratisServer;
private final NavigableMap<Long, WriteFutures> writeChunkFutureMap;

private final long writeChunkWaitMaxNs;

// keeps track of the containers created per pipeline
private final Map<Long, Long> container2BCSIDMap;
private final TaskQueueMap containerTaskQueues = new TaskQueueMap();
private final ExecutorService executor;
private final List<ThreadPoolExecutor> chunkExecutors;
private final Map<Long, Long> applyTransactionCompletionMap;
private final Set<Long> unhealthyContainers;
private final Cache<Long, ByteString> stateMachineDataCache;
private final AtomicBoolean stateMachineHealthy;

private final Semaphore applyTransactionSemaphore;
private final boolean waitOnBothFollowers;
private final HddsDatanodeService datanodeService;
private static Semaphore semaphore = new Semaphore(1);
private final AtomicBoolean peersValidated;

/**
* CSM metrics.
*/
private final CSMMetrics metrics;

static class TaskQueueMap {
private final Map<Long, TaskQueue> map = new HashMap<>();
Expand Down Expand Up @@ -217,35 +245,6 @@ long getStartTime() {
}
}

private final SimpleStateMachineStorage storage =
new SimpleStateMachineStorage();
private final ContainerDispatcher dispatcher;
private final ContainerController containerController;
private final XceiverServerRatis ratisServer;
private final NavigableMap<Long, WriteFutures> writeChunkFutureMap;
private final long writeChunkWaitMaxNs;

// keeps track of the containers created per pipeline
private final Map<Long, Long> container2BCSIDMap;
private final TaskQueueMap containerTaskQueues = new TaskQueueMap();
private final ExecutorService executor;
private final List<ThreadPoolExecutor> chunkExecutors;
private final Map<Long, Long> applyTransactionCompletionMap;
private final Set<Long> unhealthyContainers;
private final Cache<Long, ByteString> stateMachineDataCache;
private final AtomicBoolean stateMachineHealthy;

private final Semaphore applyTransactionSemaphore;
private final boolean waitOnBothFollowers;
private final HddsDatanodeService datanodeService;
private static Semaphore semaphore = new Semaphore(1);
private final AtomicBoolean peersValidated;

/**
* CSM metrics.
*/
private final CSMMetrics metrics;

@SuppressWarnings("parameternumber")
public ContainerStateMachine(HddsDatanodeService hddsDatanodeService, RaftGroupId gid,
ContainerDispatcher dispatcher,
Expand Down
Loading