use of alluxio.hub.proto.AlluxioNodeType in project alluxio by Alluxio.
the class ProcessLauncherTest method testCreateProcwithMock.
void testCreateProcwithMock(Process mockedProcess) throws Exception {
InstancedConfiguration conf = getTestConfig();
conf.set(PropertyKey.HOME, "/path/to/non/existent/directory");
try (MockedStatic<Files> files = Mockito.mockStatic(Files.class)) {
files.when(() -> Files.exists(ArgumentMatchers.any())).thenReturn(true);
ProcessLauncher l = new ProcessLauncher(getTestConfig());
try (MockedStatic<Runtime> runtimeMock = Mockito.mockStatic(Runtime.class)) {
Runtime mockedRuntime = mock(Runtime.class);
runtimeMock.when(Runtime::getRuntime).thenReturn(mockedRuntime);
for (AlluxioNodeType t : AlluxioNodeType.values()) {
doReturn(mockedProcess).when(mockedRuntime).exec(ArgumentMatchers.any(String.class));
l.start(t);
verify(mockedRuntime).exec(ArgumentMatchers.contains("alluxio-start.sh " + t.toString().toLowerCase()));
}
}
}
}
use of alluxio.hub.proto.AlluxioNodeType in project alluxio by Alluxio.
the class AgentManagerService method processStatusChange.
@Override
public void processStatusChange(AgentProcessStatusChangeRequest request, StreamObserver<AgentProcessStatusChangeResponse> responseObserver) {
RpcUtils.call(LOG, () -> {
Preconditions.checkArgument(request.hasAction());
Set<AlluxioNodeType> types = request.hasNodeType() ? Collections.singleton(request.getNodeType()) : mCtx.alluxioProcesses();
for (AlluxioNodeType t : types) {
try {
mCtx.changeState(t, request.getAction());
} catch (IOException | InterruptedException | TimeoutException e) {
throw AlluxioStatusException.fromCheckedException(e);
}
}
return AgentProcessStatusChangeResponse.newBuilder().setRequest(request).setSuccess(true).build();
}, "processStatusChange", "attempts to change the state of an Alluxio process", responseObserver, request);
}
use of alluxio.hub.proto.AlluxioNodeType in project alluxio by Alluxio.
the class ManagerProcessContext method setPrestoConfDir.
/**
* Set Presto configuration directory.
* @param request presto conf directory request
* @return response object
*/
public SetPrestoConfDirResponse.Payload setPrestoConfDir(SetPrestoConfDirRequest request) {
String confDir = request.getPayload().getConfDir();
SetPrestoConfDirResponse.Payload.Builder builder = SetPrestoConfDirResponse.Payload.newBuilder();
List<AlluxioNodeType> nodeTypes = ImmutableList.of(AlluxioNodeType.MASTER, AlluxioNodeType.WORKER);
Map<String, String> map = ImmutableMap.of(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getName(), confDir);
if (nodeTypes.stream().map(type -> execOnHub((client) -> client.setPrestoConfDir(AgentSetPrestoConfRequest.newBuilder().putAllProps(map).build()), type)).allMatch(response -> response.values().stream().allMatch(AgentSetPrestoConfResponse::getSuccess))) {
return builder.setSuccess(true).setConfDir(confDir).setIsDefault(confDir.equals(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getDefaultStringValue())).build();
} else {
String oldConfDir = getUpdatedProps(configurationSetFor(AlluxioNodeType.MASTER)).getString(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH);
return builder.setSuccess(false).setConfDir(oldConfDir).setIsDefault(oldConfDir.equals(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getDefaultStringValue())).build();
}
}
Aggregations