PSAgent { public void error(String errorMsg) { if (!exitedFlag.getAndSet(true)) { LOG.info("psagent falied"); if (executor != null) { executor.error(errorMsg); } else { stop(); } } } PSAgent(String masterIp, int masterPort, int clientIndex);  PSAgent(Configuration conf, String masterIp, int masterPort, int clientIndex);  PSAgent(Configuration conf, ApplicationId appId, String user, String masterIp,
                 int masterPort, boolean needHeartBeat, Executor executor);  PSAgent(Configuration conf, String masterIp, int masterPort, int clientIndex,
                 boolean needHeartBeat, Executor executor); void initAndStart(); void refreshMatrixInfo(); void stop(); Configuration getConf(); Location getMasterLocation(); ApplicationId getAppId(); String getUser(); TConnection getConnection(); MasterClient getMasterClient(); String getIp(); void done(); void error(String errorMsg); Location getLocation(); PSAgentLocationManager getLocationManager(); PSAgentMatrixMetaManager getMatrixMetaManager(); MatrixOpLogCache getOpLogCache(); MatrixTransportClient getMatrixTransportClient(); MatrixClient getMatrixClient(int matrixId); MatrixClient getMatrixClient(int matrixId, int taskIndex); MatrixClient getMatrixClient(String matrixName); MatrixClient getMatrixClient(String matrixName, int taskIndex); int getHeartbeatIntervalMs(); Map<String, String> getMetrics(); ConsistencyController getConsistencyController(); ClockCache getClockCache(); MatricesCache getMatricesCache(); void createMatrix(MatrixContext matrixContext, long timeOutMs); MatrixMeta getMatrix(String matrixName); void releaseMatricesUseName(List<String> matrixNames); void releaseMatrix(String matrixName); void releaseMatrices(List<Integer> matrixIds); void releaseMatrix(int matrixId); void createMatrices(List<MatrixContext> matrixContexts, long timeOutMs); List<MatrixMeta> getMatrices(List<String> matrixNames); MatrixStorageManager getMatrixStorageManager(); UserRequestAdapter getUserRequestAdapter(); RunningMode getRunningMode(); Executor getExecutor(); int getId(); TConnection getControlConnectManager(); PSControlClientManager getPsControlClientManager();  }
@Test public void testTaskContext() throws Exception { try { AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster(); assertTrue(angelAppMaster != null); AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager(); assertTrue(taskManager != null); WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager(); assertTrue(workerManager != null); Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker(); assertTrue(worker != null); PSAgent psAgent = worker.getPSAgent(); assertTrue(psAgent != null); PSAgentContext psAgentContext = PSAgentContext.get(); assertTrue(psAgentContext.getPsAgent() != null); TaskContext taskContext1 = psAgentContext.getTaskContext(1); TaskContext taskContext2 = psAgentContext.getTaskContext(2); assertTrue(taskContext1 != null); assertTrue(taskContext2 != null); assertEquals(taskContext1.getIndex(), 1); assertEquals(taskContext2.getIndex(), 2); assertEquals(taskContext1.getEpoch(), 0); assertEquals(taskContext2.getEpoch(), 0); assertEquals(taskContext1.getMatrixClock(1), 0); assertEquals(taskContext2.getMatrixClock(2), 0); assertEquals(taskContext1.getMatrixClocks().size(), 1); assertEquals(taskContext2.getMatrixClocks().size(), 1); assertEquals(taskContext1.getProgress(), 0.0, 1e-5); assertEquals(taskContext2.getProgress(), 0.0, 1e-5); } catch (Exception x) { LOG.error("run testTaskContext failed ", x); throw x; } }