Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -19,7 +19,6 @@

import com.google.common.base.Preconditions;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -28,11 +27,10 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.container.ContainerManager;
import org.apache.hadoop.hdds.scm.ha.SCMHAInvocationHandler;
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.metadata.DBTransactionBuffer;
import org.apache.hadoop.hdds.utils.db.Table;
Expand Down Expand Up @@ -300,18 +298,11 @@ public DeletedBlockLogStateManager build() {
Preconditions.checkNotNull(conf);
Preconditions.checkNotNull(table);

final DeletedBlockLogStateManager impl =
new DeletedBlockLogStateManagerImpl(conf, table, containerManager,
transactionBuffer);
final DeletedBlockLogStateManager impl = new DeletedBlockLogStateManagerImpl(
conf, table, containerManager, transactionBuffer);

final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(SCMRatisProtocol.RequestType.BLOCK,
impl, scmRatisServer);

return (DeletedBlockLogStateManager) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{DeletedBlockLogStateManager.class},
invocationHandler);
return scmRatisServer.getProxyHandler(RequestType.BLOCK,
DeletedBlockLogStateManager.class, impl);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Striped;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -58,7 +57,6 @@
import org.apache.hadoop.hdds.scm.container.states.ContainerState;
import org.apache.hadoop.hdds.scm.container.states.ContainerStateMap;
import org.apache.hadoop.hdds.scm.ha.ExecutionUtil;
import org.apache.hadoop.hdds.scm.ha.SCMHAInvocationHandler;
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.metadata.DBTransactionBuffer;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
Expand Down Expand Up @@ -609,13 +607,8 @@ public ContainerStateManager build() throws IOException {
conf, pipelineMgr, table, transactionBuffer,
containerReplicaPendingOps);

final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(RequestType.CONTAINER, csm,
scmRatisServer);

return (ContainerStateManager) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{ContainerStateManager.class}, invocationHandler);
return scmRatisServer.getProxyHandler(RequestType.CONTAINER,
ContainerStateManager.class, csm);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.protobuf.InvalidProtocolBufferException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
Expand Down Expand Up @@ -291,5 +292,15 @@ public GrpcTlsConfig getGrpcTlsConfig() {
public RaftPeerId getLeaderId() {
return leaderId;
}

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.

Please remove this change.

@Override
@SuppressWarnings("unchecked")
public <T> T getProxyHandler(RequestType type, Class<T> intf, T impl) {
final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(type, impl, this);
return (T) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] {intf}, invocationHandler);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ SCMRatisResponse submitRequest(SCMRatisRequest request)

RaftPeerId getLeaderId();

<T> T getProxyHandler(RequestType type, Class<T> intf, T supplier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Preconditions;
import jakarta.annotation.Nullable;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -429,4 +430,14 @@ public RaftPeer getLeader() {
division.getRaftConf().getPeer(RaftPeerId.valueOf(leaderId));
}
}

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.

can we remove this change too?

@Override
@SuppressWarnings("unchecked")
public <T> T getProxyHandler(final RequestType type, final Class<T> intf, final T impl) {
final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(type, impl, this);
return (T) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] {intf}, invocationHandler);
}
Comment thread
nandakumar131 marked this conversation as resolved.
Outdated

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.google.common.base.Preconditions;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.math.BigInteger;
import java.security.cert.X509Certificate;
import java.time.LocalDate;
Expand Down Expand Up @@ -330,13 +329,7 @@ public StateManager build() {

final StateManager impl = new StateManagerImpl(table, buffer);

final SCMHAInvocationHandler invocationHandler
= new SCMHAInvocationHandler(SEQUENCE_ID, impl, ratisServer);

return (StateManager) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{StateManager.class},
invocationHandler);
return ratisServer.getProxyHandler(SEQUENCE_ID, StateManager.class, impl);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.base.Preconditions;
import com.google.protobuf.ByteString;
import java.io.IOException;
import java.lang.reflect.Proxy;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
import org.apache.hadoop.hdds.scm.metadata.DBTransactionBuffer;
import org.apache.hadoop.hdds.utils.db.Table;
Expand Down Expand Up @@ -135,13 +134,8 @@ public StatefulServiceStateManager build() {
new StatefulServiceStateManagerImpl(statefulServiceConfig,
transactionBuffer);

final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(RequestType.STATEFUL_SERVICE_CONFIG,
stateManager, scmRatisServer);

return (StatefulServiceStateManager) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{StatefulServiceStateManager.class}, invocationHandler);
return scmRatisServer.getProxyHandler(RequestType.STATEFUL_SERVICE_CONFIG,
StatefulServiceStateManager.class, stateManager);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.base.Preconditions;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.List;
import java.util.NavigableSet;
Expand All @@ -28,9 +27,8 @@
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol;
import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.ha.SCMHAInvocationHandler;
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.metadata.DBTransactionBuffer;
import org.apache.hadoop.hdds.scm.node.NodeManager;
Expand Down Expand Up @@ -380,13 +378,8 @@ public PipelineStateManager build() throws IOException {
new PipelineStateManagerImpl(
pipelineStore, nodeManager, transactionBuffer);

final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(SCMRatisProtocol.RequestType.PIPELINE,
pipelineStateManager, scmRatisServer);

return (PipelineStateManager) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{PipelineStateManager.class}, invocationHandler);
return scmRatisServer.getProxyHandler(RequestType.PIPELINE,
PipelineStateManager.class, pipelineStateManager);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Proxy;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.hdds.scm.ha.SCMHAInvocationHandler;
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.hdds.security.SecurityConfig;
Expand Down Expand Up @@ -230,13 +228,8 @@ public RootCARotationHandler build() {
final RootCARotationHandler impl =
new RootCARotationHandlerImpl(scm, rootCARotationManager);

final SCMHAInvocationHandler invocationHandler
= new SCMHAInvocationHandler(CERT_ROTATE, impl, ratisServer);

return (RootCARotationHandler) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{RootCARotationHandler.class},
invocationHandler);
return ratisServer.getProxyHandler(CERT_ROTATE,
RootCARotationHandler.class, impl);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public GrpcTlsConfig getGrpcTlsConfig() {
public RaftPeerId getLeaderId() {
return RaftPeerId.valueOf(UUID.randomUUID().toString());
}

@Override
public <T> T getProxyHandler(RequestType type, Class<T> intf, T impl) {
return impl;
}

};
}

Expand Down