startTime = Math.max(startTime, currentState.getStartTime(partition.getPartitionName()));
long fromTopStateStartTime = currentState.getStartTime(partition.getPartitionName()); if (fromTopStateStartTime > startTime) { startTime = fromTopStateStartTime; currentState.getEndTime(partition.getPartitionName()) - startTime; startTime = Math.max(startTime, currentState.getStartTime(partition.getPartitionName()));
long toTopStateuserLatency = endTime - cache.getCurrentState(curTopStateInstance, curTopStateSession).get(resourceName) .getStartTime(partition.getPartitionName()); startTime = cache.getCurrentState(lastTopStateInstance, lastTopStateSession).get(resourceName) .getStartTime(partition.getPartitionName()); fromTopStateUserLatency = cache.getCurrentState(lastTopStateInstance, lastTopStateSession).get(resourceName)
@Test public void testAddedFieldsInCurrentState() { String instanceName = PARTICIPANT_PREFIX + "_" + _startPort; HelixDataAccessor accessor = _manager.getHelixDataAccessor(); LiveInstance liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName)); CurrentState currentState = accessor.getProperty(accessor.keyBuilder() .currentState(instanceName, liveInstance.getSessionId(), WorkflowGenerator.DEFAULT_TGT_DB)); // Test start time should happen after test start time Assert.assertTrue( currentState.getStartTime(WorkflowGenerator.DEFAULT_TGT_DB + "_0") >= _testStartTime); // Test end time is always larger than start time Assert.assertTrue( currentState.getEndTime(WorkflowGenerator.DEFAULT_TGT_DB + "_0") >= currentState .getStartTime(WorkflowGenerator.DEFAULT_TGT_DB + "_0")); // Final state is MASTER, so SLAVE will be the previous state Assert.assertEquals(currentState.getPreviousState(WorkflowGenerator.DEFAULT_TGT_DB + "_0"), "SLAVE"); } }
handOffEndTime = currentState.getEndTime(partition.getPartitionName()); toTopStateUserLatency = handOffEndTime - currentState.getStartTime(partition.getPartitionName());
private void verifyP2PEnabled(long startTime) { ClusterDataCache dataCache = new ClusterDataCache(CLUSTER_NAME); dataCache.refresh(_accessor); Map<String, LiveInstance> liveInstanceMap = dataCache.getLiveInstances(); for (LiveInstance instance : liveInstanceMap.values()) { Map<String, CurrentState> currentStateMap = dataCache.getCurrentState(instance.getInstanceName(), instance.getSessionId()); Assert.assertNotNull(currentStateMap); for (CurrentState currentState : currentStateMap.values()) { for (String partition : currentState.getPartitionStateMap().keySet()) { String state = currentState.getState(partition); long start = currentState.getStartTime(partition); if (state.equalsIgnoreCase("MASTER") && start > startTime) { String triggerHost = currentState.getTriggerHost(partition); if (!triggerHost.equals(_controllerName)) { p2pTrigged ++; } total ++; } } } } }