Class AbstractEnv
java.lang.Object
org.apache.iotdb.it.env.cluster.env.AbstractEnv
- All Implemented Interfaces:
BaseEnv
- Direct Known Subclasses:
AIEnv,Cluster1Env,MultiClusterEnv,SimpleEnv
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<AINodeWrapper>protected List<ConfigNodeWrapper>protected List<DataNodeWrapper>protected intprotected intprotected longprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckClusterStatus(Predicate<Map<Integer, String>> statusCheck) check whether all nodes' status match the provided predicate with RPC.voidvoidvoidcheckNodeInStatus(int nodeId, NodeStatus expectation) voidDestroy the cluster and all the configurations.dataNodeIdToWrapper(int nodeId) voidvoidensureNodeStatus(List<BaseNodeWrapper> nodes, List<NodeStatus> targetStatus) Ensure all the nodes being in the corresponding status.Get aConfigNodeWrapperrandomly.Get aDataNodeWrapperrandomly.Return theClusterConfigfor developers to set values before test.getConfigNodeConnection(int index) getConfigNodeWrapper(int index) Get theConfigNodeWrapperof the specified index.getConnection(String username, String password) getConnection(DataNodeWrapper dataNodeWrapper, String username, String password) getConnection(Constant.Version version, String username, String password) getConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, String username, String password) getDataNodeWrapper(int index) Get theDataNodeWrapperof the specified index.intGet the index of the first dataNode with a SchemaRegion leader.getIP()Get connection to ConfigNode-Leader in ClusterIT environmentintGet the index of the ConfigNode leader.getMetricPrometheusReporterContents(String authHeader) Return the content of prometheusintgetPort()protected List<NodeConnection>getReadConnections(Constant.Version version, String username, String password) protected List<NodeConnection>getReadConnections(Constant.Version version, DataNodeWrapper dataNode, String username, String password) getSessionConnection(String userName, String password) getSessionConnection(ZoneId zoneId) getSessionConnection(List<String> nodeUrls) getSessionPool(int maxSize) protected NodeConnectiongetWriteConnection(Constant.Version version, String username, String password) protected NodeConnectiongetWriteConnectionFromDataNodeList(List<DataNodeWrapper> dataNodeList, Constant.Version version, String username, String password) protected NodeConnectiongetWriteConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, Constant.Version version, String username, String password) getWriteOnlyConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, String username, String password) protected voidinitEnvironment(int configNodesNum, int dataNodesNum) protected voidinitEnvironment(int configNodesNum, int dataNodesNum, int testWorkingRetryCount) protected voidinitEnvironment(int configNodesNum, int dataNodesNum, int retryCount, boolean addAINode) voidregisterConfigNodeKillPoints(List<String> killPoints) voidregisterDataNodeKillPoints(List<String> killPoints) voidregisterNewConfigNode(boolean isNeedVerify) Register a new ConfigNode with random ports.voidregisterNewConfigNode(ConfigNodeWrapper newConfigNodeWrapper, boolean isNeedVerify) Register a new DataNode with specified ConfigNodeWrapper.voidregisterNewDataNode(boolean isNeedVerify) Register a new DataNode with random ports.voidregisterNewDataNode(DataNodeWrapper newDataNodeWrapper, boolean isNeedVerify) Register a new DataNode with specified DataNodeWrapper.voidsetTestMethodName(String testMethodName) voidShutdown all existed ConfigNodes.voidShutdown all existed DataNodes.voidshutdownConfigNode(int index) Shutdown an existed ConfigNode.voidshutdownDataNode(int index) Shutdown an existed DataNode.voidvoidShutdown forcibly all existed DataNodes.voidStart all existed ConfigNodes.voidStart all existed DataNodes.voidstartConfigNode(int index) Start an existed ConfigNode.voidstartDataNode(int index) Start an existed DataNode.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.iotdb.itbase.env.BaseEnv
getConnection, getConnection, getConnectionWithSpecifiedDataNode, getUrlContent, getWriteOnlyConnectionWithSpecifiedDataNode, initClusterEnvironment, initClusterEnvironment, initClusterEnvironment
-
Field Details
-
configNodeWrapperList
-
dataNodeWrapperList
-
aiNodeWrapperList
-
testMethodName
-
index
protected int index -
startTime
protected long startTime -
retryCount
protected int retryCount
-
-
Constructor Details
-
AbstractEnv
protected AbstractEnv() -
AbstractEnv
protected AbstractEnv(long startTime)
-
-
Method Details
-
getConfig
Description copied from interface:BaseEnvReturn theClusterConfigfor developers to set values before test. -
getMetricPrometheusReporterContents
Description copied from interface:BaseEnvReturn the content of prometheus- Specified by:
getMetricPrometheusReporterContentsin interfaceBaseEnv
-
initEnvironment
protected void initEnvironment(int configNodesNum, int dataNodesNum) -
initEnvironment
protected void initEnvironment(int configNodesNum, int dataNodesNum, int testWorkingRetryCount) -
initEnvironment
protected void initEnvironment(int configNodesNum, int dataNodesNum, int retryCount, boolean addAINode) -
getTestClassName
-
checkNodeInStatus
-
checkClusterStatusWithoutUnknown
public void checkClusterStatusWithoutUnknown() -
checkClusterStatusOneUnknownOtherRunning
public void checkClusterStatusOneUnknownOtherRunning() -
checkClusterStatus
check whether all nodes' status match the provided predicate with RPC. after retryCount times, if the status of all nodes still not match the predicate, throw AssertionError.- Parameters:
statusCheck- the predicate to test the status of nodes
-
cleanClusterEnvironment
public void cleanClusterEnvironment()Description copied from interface:BaseEnvDestroy the cluster and all the configurations.- Specified by:
cleanClusterEnvironmentin interfaceBaseEnv
-
getConnection
- Specified by:
getConnectionin interfaceBaseEnv- Throws:
SQLException
-
getConnection
public Connection getConnection(DataNodeWrapper dataNodeWrapper, String username, String password) throws SQLException - Specified by:
getConnectionin interfaceBaseEnv- Throws:
SQLException
-
getWriteOnlyConnectionWithSpecifiedDataNode
public Connection getWriteOnlyConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, String username, String password) throws SQLException - Specified by:
getWriteOnlyConnectionWithSpecifiedDataNodein interfaceBaseEnv- Throws:
SQLException
-
getConnectionWithSpecifiedDataNode
public Connection getConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, String username, String password) throws SQLException - Specified by:
getConnectionWithSpecifiedDataNodein interfaceBaseEnv- Throws:
SQLException
-
getConnection
public Connection getConnection(Constant.Version version, String username, String password) throws SQLException - Specified by:
getConnectionin interfaceBaseEnv- Throws:
SQLException
-
getSessionConnection
- Specified by:
getSessionConnectionin interfaceBaseEnv- Throws:
IoTDBConnectionException
-
getSessionConnection
- Specified by:
getSessionConnectionin interfaceBaseEnv- Throws:
IoTDBConnectionException
-
getSessionConnection
public ISession getSessionConnection(String userName, String password) throws IoTDBConnectionException - Specified by:
getSessionConnectionin interfaceBaseEnv- Throws:
IoTDBConnectionException
-
getSessionConnection
- Specified by:
getSessionConnectionin interfaceBaseEnv- Throws:
IoTDBConnectionException
-
getSessionPool
- Specified by:
getSessionPoolin interfaceBaseEnv
-
getWriteConnection
protected NodeConnection getWriteConnection(Constant.Version version, String username, String password) throws SQLException - Throws:
SQLException
-
getWriteConnectionWithSpecifiedDataNode
protected NodeConnection getWriteConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode, Constant.Version version, String username, String password) throws SQLException - Throws:
SQLException
-
getWriteConnectionFromDataNodeList
protected NodeConnection getWriteConnectionFromDataNodeList(List<DataNodeWrapper> dataNodeList, Constant.Version version, String username, String password) throws SQLException - Throws:
SQLException
-
getReadConnections
protected List<NodeConnection> getReadConnections(Constant.Version version, String username, String password) throws SQLException - Throws:
SQLException
-
getReadConnections
protected List<NodeConnection> getReadConnections(Constant.Version version, DataNodeWrapper dataNode, String username, String password) throws SQLException - Throws:
SQLException
-
testJDBCConnection
protected void testJDBCConnection() -
getTestMethodName
-
setTestMethodName
- Specified by:
setTestMethodNamein interfaceBaseEnv
-
dumpTestJVMSnapshot
public void dumpTestJVMSnapshot()- Specified by:
dumpTestJVMSnapshotin interfaceBaseEnv
-
getNodeWrapperList
- Specified by:
getNodeWrapperListin interfaceBaseEnv
-
getConfigNodeWrapperList
- Specified by:
getConfigNodeWrapperListin interfaceBaseEnv
-
getDataNodeWrapperList
- Specified by:
getDataNodeWrapperListin interfaceBaseEnv
-
getLeaderConfigNodeConnection
public IConfigNodeRPCService.Iface getLeaderConfigNodeConnection() throws IOException, InterruptedExceptionGet connection to ConfigNode-Leader in ClusterIT environmentNotice: The caller should always use try-with-resource to invoke this interface in order to return client to ClientPool automatically
- Specified by:
getLeaderConfigNodeConnectionin interfaceBaseEnv- Returns:
SyncConfigNodeIServiceClientthat connects to the ConfigNode-Leader- Throws:
IOExceptionInterruptedException
-
getConfigNodeConnection
- Specified by:
getConfigNodeConnectionin interfaceBaseEnv- Throws:
Exception
-
getFirstLeaderSchemaRegionDataNodeIndex
Description copied from interface:BaseEnvGet the index of the first dataNode with a SchemaRegion leader.- Specified by:
getFirstLeaderSchemaRegionDataNodeIndexin interfaceBaseEnv- Returns:
- The index of DataNode with SchemaRegion-leader in dataNodeWrapperList
- Throws:
IOExceptionInterruptedException
-
getLeaderConfigNodeIndex
Description copied from interface:BaseEnvGet the index of the ConfigNode leader.- Specified by:
getLeaderConfigNodeIndexin interfaceBaseEnv- Returns:
- The index of ConfigNode-Leader in configNodeWrapperList
- Throws:
IOExceptionInterruptedException
-
startConfigNode
public void startConfigNode(int index) Description copied from interface:BaseEnvStart an existed ConfigNode.- Specified by:
startConfigNodein interfaceBaseEnv
-
startAllConfigNodes
public void startAllConfigNodes()Description copied from interface:BaseEnvStart all existed ConfigNodes.- Specified by:
startAllConfigNodesin interfaceBaseEnv
-
shutdownConfigNode
public void shutdownConfigNode(int index) Description copied from interface:BaseEnvShutdown an existed ConfigNode.- Specified by:
shutdownConfigNodein interfaceBaseEnv
-
shutdownAllConfigNodes
public void shutdownAllConfigNodes()Description copied from interface:BaseEnvShutdown all existed ConfigNodes.- Specified by:
shutdownAllConfigNodesin interfaceBaseEnv
-
shutdownForciblyAllConfigNodes
public void shutdownForciblyAllConfigNodes()- Specified by:
shutdownForciblyAllConfigNodesin interfaceBaseEnv
-
getConfigNodeWrapper
Description copied from interface:BaseEnvGet theConfigNodeWrapperof the specified index.- Specified by:
getConfigNodeWrapperin interfaceBaseEnv- Returns:
- The ConfigNodeWrapper of the specified index
-
getDataNodeWrapper
Description copied from interface:BaseEnvGet theDataNodeWrapperof the specified index.- Specified by:
getDataNodeWrapperin interfaceBaseEnv- Returns:
- The DataNodeWrapper of the specified index
-
generateRandomConfigNodeWrapper
Description copied from interface:BaseEnvGet aConfigNodeWrapperrandomly.- Specified by:
generateRandomConfigNodeWrapperin interfaceBaseEnv- Returns:
- A random available ConfigNodeWrapper
-
generateRandomDataNodeWrapper
Description copied from interface:BaseEnvGet aDataNodeWrapperrandomly.- Specified by:
generateRandomDataNodeWrapperin interfaceBaseEnv- Returns:
- A random available ConfigNodeWrapper
-
registerNewDataNode
public void registerNewDataNode(boolean isNeedVerify) Description copied from interface:BaseEnvRegister a new DataNode with random ports.- Specified by:
registerNewDataNodein interfaceBaseEnv
-
registerNewConfigNode
public void registerNewConfigNode(boolean isNeedVerify) Description copied from interface:BaseEnvRegister a new ConfigNode with random ports.- Specified by:
registerNewConfigNodein interfaceBaseEnv
-
registerNewConfigNode
Description copied from interface:BaseEnvRegister a new DataNode with specified ConfigNodeWrapper.- Specified by:
registerNewConfigNodein interfaceBaseEnv
-
registerNewDataNode
Description copied from interface:BaseEnvRegister a new DataNode with specified DataNodeWrapper.- Specified by:
registerNewDataNodein interfaceBaseEnv
-
startDataNode
public void startDataNode(int index) Description copied from interface:BaseEnvStart an existed DataNode.- Specified by:
startDataNodein interfaceBaseEnv
-
startAllDataNodes
public void startAllDataNodes()Description copied from interface:BaseEnvStart all existed DataNodes.- Specified by:
startAllDataNodesin interfaceBaseEnv
-
shutdownDataNode
public void shutdownDataNode(int index) Description copied from interface:BaseEnvShutdown an existed DataNode.- Specified by:
shutdownDataNodein interfaceBaseEnv
-
shutdownAllDataNodes
public void shutdownAllDataNodes()Description copied from interface:BaseEnvShutdown all existed DataNodes.- Specified by:
shutdownAllDataNodesin interfaceBaseEnv
-
shutdownForciblyAllDataNodes
public void shutdownForciblyAllDataNodes()Description copied from interface:BaseEnvShutdown forcibly all existed DataNodes.- Specified by:
shutdownForciblyAllDataNodesin interfaceBaseEnv
-
ensureNodeStatus
public void ensureNodeStatus(List<BaseNodeWrapper> nodes, List<NodeStatus> targetStatus) throws IllegalStateException Description copied from interface:BaseEnvEnsure all the nodes being in the corresponding status.- Specified by:
ensureNodeStatusin interfaceBaseEnv- Parameters:
nodes- the nodes list to query.targetStatus- the targetNodeStatusof each node. It should have the same length with nodes.- Throws:
IllegalStateException- if there are some nodes not in the targetStatus after a period times of check.
-
getMqttPort
public int getMqttPort()- Specified by:
getMqttPortin interfaceBaseEnv
-
getIP
-
getPort
-
getSbinPath
- Specified by:
getSbinPathin interfaceBaseEnv
-
getToolsPath
- Specified by:
getToolsPathin interfaceBaseEnv
-
getLibPath
- Specified by:
getLibPathin interfaceBaseEnv
-
dataNodeIdToWrapper
- Specified by:
dataNodeIdToWrapperin interfaceBaseEnv
-
registerConfigNodeKillPoints
- Specified by:
registerConfigNodeKillPointsin interfaceBaseEnv
-
registerDataNodeKillPoints
- Specified by:
registerDataNodeKillPointsin interfaceBaseEnv
-