use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.
the class QuorumCommandIntegrationTest method infoAfterElect.
@Test
public void infoAfterElect() throws Exception {
final int MASTER_INDEX_WAIT_TIME = 5_000;
int numMasters = 3;
mCluster = MultiProcessCluster.newBuilder(PortCoordination.QUORUM_SHELL_REMOVE).setClusterName("QuorumShellElect").setNumMasters(numMasters).setNumWorkers(0).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % numMasters;
// `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
// we can therefore access to the new leader's address this ways
MasterNetAddress netAddress = mCluster.getMasterAddresses().get(newLeaderIdx);
String newLeaderAddr = String.format("%s:%s", netAddress.getHostname(), netAddress.getEmbeddedJournalPort());
int success = shell.run("journal", "quorum", "elect", "-address", newLeaderAddr);
Assert.assertEquals("elect command failed", 0, success);
mOutput.reset();
shell.run("journal", "quorum", "info", "-domain", "MASTER");
String output = mOutput.toString().trim();
for (MasterNetAddress masterAddr : mCluster.getMasterAddresses()) {
String expected = String.format(QuorumInfoCommand.OUTPUT_SERVER_INFO, "AVAILABLE", "1", String.format("%s:%d", masterAddr.getHostname(), masterAddr.getEmbeddedJournalPort()));
Assert.assertTrue(output.contains(expected.trim()));
}
}
mCluster.notifySuccess();
}
use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.
the class AddCommandIntegrationTest method overwriteProperty.
@Test
public void overwriteProperty() throws Exception {
try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
int ret = shell.run("pathConf", "add", "--property", READ_TYPE_NO_CACHE, "/");
Assert.assertEquals(0, ret);
mOutput.reset();
ret = shell.run("pathConf", "show", "/");
Assert.assertEquals(0, ret);
Assert.assertEquals(READ_TYPE_NO_CACHE + "\n", mOutput.toString());
ret = shell.run("pathConf", "add", "--property", READ_TYPE_CACHE, "/");
Assert.assertEquals(0, ret);
mOutput.reset();
ret = shell.run("pathConf", "show", "/");
Assert.assertEquals(0, ret);
Assert.assertEquals(READ_TYPE_CACHE + "\n", mOutput.toString());
}
}
use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.
the class AddCommandIntegrationTest method immediatelyEffectiveForShellCommands.
@Test
public void immediatelyEffectiveForShellCommands() throws Exception {
// Tests that after adding some path configuration, it's immediately effective for command
// line calls afterwards.
InstancedConfiguration conf = ServerConfiguration.global();
try (FileSystemShell fsShell = new FileSystemShell(conf);
FileSystemAdminShell fsAdminShell = new FileSystemAdminShell(conf)) {
Assert.assertEquals(0, fsAdminShell.run("pathConf", "add", "--property", WRITE_TYPE_THROUGH, PATH1));
Assert.assertEquals(0, fsAdminShell.run("pathConf", "add", "--property", WRITE_TYPE_CACHE_THROUGH, PATH2));
FileSystem fs = sLocalAlluxioClusterResource.get().getClient();
String file = "/file";
FileSystemTestUtils.createByteFile(fs, file, 100, CreateFilePOptions.getDefaultInstance());
fs.createDirectory(new AlluxioURI(PATH1), CreateDirectoryPOptions.newBuilder().setRecursive(true).build());
fs.createDirectory(new AlluxioURI(PATH2), CreateDirectoryPOptions.newBuilder().setRecursive(true).build());
AlluxioURI target = new AlluxioURI(PATH1 + file);
Assert.assertEquals(0, fsShell.run("cp", file, target.toString()));
URIStatus status = fs.getStatus(target);
Assert.assertEquals(0, status.getInMemoryPercentage());
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
target = new AlluxioURI(PATH2 + file);
Assert.assertEquals(0, fsShell.run("cp", file, target.toString()));
status = fs.getStatus(target);
Assert.assertEquals(100, status.getInMemoryPercentage());
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
}
}
use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.
the class AddCommandIntegrationTest method addNoProperty.
@Test
public void addNoProperty() throws Exception {
try (FileSystemAdminShell shell = new FileSystemAdminShell(ServerConfiguration.global())) {
int ret = shell.run("pathConf", "add", "/");
Assert.assertEquals(0, ret);
}
}
use of alluxio.cli.fsadmin.FileSystemAdminShell in project alluxio by Alluxio.
the class ShowCommandIntegrationTest method showDir1.
@Test
public void showDir1() throws Exception {
try (FileSystemAdminShell shell = new FileSystemAdminShell(setPathConfigurations())) {
int ret = shell.run("pathConf", "show", DIR1);
Assert.assertEquals(0, ret);
String expected = format(PROPERTY_KEY11, PROPERTY_VALUE11) + "\n" + format(PROPERTY_KEY12, PROPERTY_VALUE12) + "\n";
String output = mOutput.toString();
Assert.assertEquals(expected, output);
}
}
Aggregations