use of alluxio.master.MasterInquireClient in project alluxio by Alluxio.
the class FileSystemMasterClientPoolTest method create.
@Test
public void create() throws Exception {
AlluxioConfiguration conf = ConfigurationTestUtils.defaults();
FileSystemMasterClient expectedClient = Mockito.mock(FileSystemMasterClient.class);
PowerMockito.mockStatic(FileSystemMasterClient.Factory.class);
Mockito.when(FileSystemMasterClient.Factory.create(Mockito.any(MasterClientContext.class))).thenReturn(expectedClient);
FileSystemMasterClient client;
ClientContext clientContext = ClientContext.create(conf);
MasterInquireClient masterInquireClient = MasterInquireClient.Factory.create(conf, clientContext.getUserState());
MasterClientContext masterClientContext = MasterClientContext.newBuilder(clientContext).setMasterInquireClient(masterInquireClient).build();
try (FileSystemMasterClientPool pool = new FileSystemMasterClientPool(masterClientContext)) {
client = pool.acquire();
assertEquals(expectedClient, client);
pool.release(client);
}
Mockito.verify(client).close();
}
use of alluxio.master.MasterInquireClient in project alluxio by Alluxio.
the class BlockMasterClientPoolTest method create.
@Test
public void create() throws Exception {
BlockMasterClient expectedClient = mock(BlockMasterClient.class);
PowerMockito.mockStatic(BlockMasterClient.Factory.class);
when(BlockMasterClient.Factory.create(any(MasterClientContext.class))).thenReturn(expectedClient);
BlockMasterClient client;
ClientContext clientContext = ClientContext.create(mConf);
MasterInquireClient masterInquireClient = MasterInquireClient.Factory.create(mConf, clientContext.getUserState());
MasterClientContext masterClientContext = MasterClientContext.newBuilder(clientContext).setMasterInquireClient(masterInquireClient).build();
try (BlockMasterClientPool pool = new BlockMasterClientPool(masterClientContext)) {
client = pool.acquire();
assertEquals(expectedClient, client);
pool.release(client);
}
verify(client).close();
}
use of alluxio.master.MasterInquireClient in project alluxio by Alluxio.
the class LeaderCommand method run.
@Override
public int run(CommandLine cl) {
System.out.println("This command will be deprecated as of v3.0, please use masterInfo command");
try (CloseableResource<FileSystemMasterClient> client = mFsContext.acquireMasterClientResource()) {
try {
InetSocketAddress address = client.get().getAddress();
System.out.println(address.getHostName());
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), mFsContext.getClusterConf());
try {
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
System.err.println("The leader is not currently serving requests.");
}
} catch (UnavailableException e) {
System.err.println("Failed to get the leader master.");
}
}
return 0;
}
use of alluxio.master.MasterInquireClient in project alluxio by Alluxio.
the class FileSystemContext method create.
/**
* @param subject the parent subject, set to null if not present
* @param conf Alluxio configuration
* @param blockWorker block worker
* @return a context
*/
public static FileSystemContext create(@Nullable Subject subject, @Nullable AlluxioConfiguration conf, @Nullable BlockWorker blockWorker) {
ClientContext ctx = ClientContext.create(subject, conf);
MasterInquireClient inquireClient = MasterInquireClient.Factory.create(ctx.getClusterConf(), ctx.getUserState());
FileSystemContext context = new FileSystemContext(ctx.getClusterConf(), blockWorker);
context.init(ctx, inquireClient);
return context;
}
use of alluxio.master.MasterInquireClient in project alluxio by Alluxio.
the class LogLevelTest method parseEmbeddedHAMasterTarget.
@Test
public void parseEmbeddedHAMasterTarget() throws Exception {
String masterAddresses = "masters-1:19200,masters-2:19200";
mConf.set(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES, masterAddresses);
CommandLine mockCommandLine = mock(CommandLine.class);
String[] mockArgs = new String[] { "--target", "master" };
when(mockCommandLine.getArgs()).thenReturn(mockArgs);
when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true);
when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]);
PowerMockito.mockStatic(MasterInquireClient.Factory.class);
MasterInquireClient mockInquireClient = mock(MasterInquireClient.class);
when(mockInquireClient.getPrimaryRpcAddress()).thenReturn(new InetSocketAddress("masters-1", mConf.getInt(PropertyKey.MASTER_RPC_PORT)));
when(mockInquireClient.getConnectDetails()).thenReturn(() -> new MultiMasterAuthority(masterAddresses));
when(MasterInquireClient.Factory.create(any(), any())).thenReturn(mockInquireClient);
List<LogLevel.TargetInfo> targets = LogLevel.parseOptTarget(mockCommandLine, mConf);
assertEquals(1, targets.size());
assertEquals(new LogLevel.TargetInfo("masters-1", MASTER_WEB_PORT, "master"), targets.get(0));
}
Aggregations