Skip to content

HDDS-6551. Introduce StatefulService in scm#3307

Merged
nandakumar131 merged 12 commits intoapache:masterfrom
siddhantsangwan:HDDS-6551
May 5, 2022
Merged

HDDS-6551. Introduce StatefulService in scm#3307
nandakumar131 merged 12 commits intoapache:masterfrom
siddhantsangwan:HDDS-6551

Conversation

@siddhantsangwan
Copy link
Contributor

@siddhantsangwan siddhantsangwan commented Apr 13, 2022

What changes were proposed in this pull request?

A StatefulService is an SCMService with an API to persist/read configuration to RocksDB and replicate it through RATIS. The configuration would be provided as a Protobuf message. This change includes an interface StatefulServiceStateManager and its implementation StatefulServiceStateManagerImpl.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-6551

How was this patch tested?

Added a unit test.

@siddhantsangwan siddhantsangwan marked this pull request as draft April 13, 2022 11:33
@siddhantsangwan siddhantsangwan marked this pull request as ready for review April 14, 2022 11:38
@siddhantsangwan
Copy link
Contributor Author

@nandakumar131 @lokeshj1703 can you please review?

Copy link
Contributor

@nandakumar131 nandakumar131 left a comment

Choose a reason for hiding this comment

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

Overall the change looks good.

Comment on lines 62 to 67
protected final Message readConfiguration(Message defaultInstanceForType)
throws IOException {
return defaultInstanceForType.getParserForType()
.parseFrom(stateManager.readConfiguration(getServiceName()));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected final Message readConfiguration(Message defaultInstanceForType)
throws IOException {
return defaultInstanceForType.getParserForType()
.parseFrom(stateManager.readConfiguration(getServiceName()));
}
}
protected final <T extends GeneratedMessage> T readConfiguration(Class<T> configType)
throws IOException {
try {
return configType.cast(ReflectionUtil.getMethod(configType,
"parseFrom", ByteString.class)
.invoke(null, stateManager.readConfiguration(getServiceName())));
} catch (NoSuchMethodException | IllegalAccessException
| InvocationTargetException ex) {
ex.printStackTrace();
throw new InvalidProtocolBufferException(
"GeneratedMessage cannot be decoded: " + ex.getMessage());
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

With this change the return type will be the exact Proto object which can be used by the service. There is no need for any type-cast by the service implementation.

return this;
}

public StatefulServiceStateManager build() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add

Preconditions.checkNotNull(statefulServiceConfig);
Preconditions.checkNotNull(transactionBuffer);
Preconditions.checkNotNull(scmRatisServer);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we exclude the not null check for scmRatisServer? SCMHAInvocationHandler takes care of the null case by calling the invokeLocal method.

@siddhantsangwan
Copy link
Contributor Author

@nandakumar131 thanks for the review. Updated.

# Conflicts:
#	hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
@nandakumar131 nandakumar131 merged commit f315500 into apache:master May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants