GlenGeng commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550069026
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/MockSCMHAManager.java
##########
@@ -15,29 +15,28 @@
* the License.
*/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
Review comment:
Hey Rui, Why we need to move MockRatisServer out of MockSCMHAManager ?
My concern is
`// TODO: Move this class to test package after fixing Recon`, I would like
to separate them until they are moved back to test dir.
You duplicated the licenses.
##########
File path:
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.hadoop.hdds.scm.ha;
+
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
Review comment:
Hey Rui, I suggested to simulate the real ratis call, what do you think ?
```
public class TestReplicationAnnotation {
@Test
public void testReplicateAnnotationBasic() throws Throwable {
final ContainerStateManagerV2 csm = new ContainerStateManagerV2() {
@Override
public boolean contains(HddsProtos.ContainerID containerID) {
return false;
}
@Override
public Set<ContainerID> getContainerIDs() {
return null;
}
@Override
public Set<ContainerID> getContainerIDs(HddsProtos.LifeCycleState
state) {
return null;
}
@Override
public ContainerInfo getContainer(HddsProtos.ContainerID id) {
return null;
}
@Override
public Set<ContainerReplica>
getContainerReplicas(HddsProtos.ContainerID id) {
return null;
}
@Override
public void updateContainerReplica(HddsProtos.ContainerID id,
ContainerReplica replica) {
}
@Override
public void removeContainerReplica(HddsProtos.ContainerID id,
ContainerReplica replica) {
}
@Override
public void addContainer(HddsProtos.ContainerInfoProto containerInfo)
throws IOException {
}
@Override
public void updateContainerState(HddsProtos.ContainerID id,
HddsProtos.LifeCycleEvent event) throws IOException,
InvalidStateTransitionException {
}
@Override
public void updateDeleteTransactionId(Map<ContainerID, Long>
deleteTransactionMap) throws IOException {
}
@Override
public ContainerInfo getMatchingContainer(long size, String owner,
PipelineID pipelineID, NavigableSet<ContainerID> containerIDs) {
return null;
}
@Override
public void removeContainer(HddsProtos.ContainerID containerInfo)
throws IOException {
}
@Override
public void close() throws IOException {
}
};
SCMRatisServer ratisServer = new SCMRatisServer() {
@Override
public void start() throws IOException {
}
@Override
public void registerStateMachineHandler(SCMRatisProtocol.RequestType
handlerType, Object handler) {
}
@Override
public SCMRatisResponse submitRequest(SCMRatisRequest request) throws
IOException, ExecutionException, InterruptedException {
throw new IOException("submitRequest is called.");
}
@Override
public void stop() throws IOException {
}
@Override
public RaftServer.Division getDivision() {
return null;
}
@Override
public List<String> getRatisRoles() {
return null;
}
@Override
public NotLeaderException triggerNotLeaderException() {
return null;
}
};
final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(
SCMRatisProtocol.RequestType.CONTAINER, csm, ratisServer);
ContainerStateManagerV2 proxy = (ContainerStateManagerV2)
Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{ContainerStateManagerV2.class}, invocationHandler);
try {
proxy.addContainer(HddsProtos.ContainerInfoProto.getDefaultInstance());
Assert.fail();
} catch (IOException ignore) {
}
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]