use of io.pravega.cli.admin.utils.AdminSegmentHelper in project pravega by pravega.
the class GetTableSegmentInfoCommand method execute.
@Override
public void execute() {
ensureArgCount(2);
final String fullyQualifiedTableSegmentName = getArg(0);
final String segmentStoreHost = getArg(1);
@Cleanup CuratorFramework zkClient = createZKClient();
@Cleanup AdminSegmentHelper adminSegmentHelper = instantiateAdminSegmentHelper(zkClient);
CompletableFuture<WireCommands.TableSegmentInfo> reply = adminSegmentHelper.getTableSegmentInfo(fullyQualifiedTableSegmentName, new PravegaNodeUri(segmentStoreHost, getServiceConfig().getAdminGatewayPort()), super.authHelper.retrieveMasterToken());
WireCommands.TableSegmentInfo tableSegmentInfo = reply.join();
output("TableSegmentInfo for %s: ", fullyQualifiedTableSegmentName);
SEGMENT_INFO_FIELD_MAP.forEach((name, f) -> output("%s = %s", name, f.apply(tableSegmentInfo)));
}
use of io.pravega.cli.admin.utils.AdminSegmentHelper in project pravega by pravega.
the class ModifyTableSegmentEntry method execute.
@Override
public void execute() {
ensureArgCount(4);
ensureSerializersExist();
final String fullyQualifiedTableSegmentName = getArg(0);
final String segmentStoreHost = getArg(1);
final String key = getArg(2);
Map<String, String> newFieldMap = parseStringData(getArg(3));
@Cleanup CuratorFramework zkClient = createZKClient();
@Cleanup AdminSegmentHelper adminSegmentHelper = instantiateAdminSegmentHelper(zkClient);
String currentValue = getTableEntry(fullyQualifiedTableSegmentName, key, segmentStoreHost, adminSegmentHelper);
List<String> changedFields = new ArrayList<>();
Map<String, String> currentValueFieldMap = parseStringData(currentValue);
// Make changes to the fields in the entry that exists currently.
// If the field name does not exist then the user is notified of the same.
newFieldMap.forEach((f, v) -> {
if (currentValueFieldMap.containsKey(f)) {
currentValueFieldMap.put(f, v);
changedFields.add(f);
} else {
output("%s field does not exist.", f);
}
});
// If no change is made to fields of the current entry then return.
if (changedFields.isEmpty()) {
output("No fields provided to modify.");
return;
}
StringBuilder updatedValueBuilder = new StringBuilder();
currentValueFieldMap.forEach((f, v) -> appendField(updatedValueBuilder, f, v));
String updatedValue = updatedValueBuilder.toString();
long version = updateTableEntry(fullyQualifiedTableSegmentName, key, updatedValue, segmentStoreHost, adminSegmentHelper);
output("Successfully modified the following fields in the value for key %s in table %s with version %s: %s", key, fullyQualifiedTableSegmentName, version, String.join(",", changedFields));
}
use of io.pravega.cli.admin.utils.AdminSegmentHelper in project pravega by pravega.
the class FlushToStorageCommand method execute.
@Override
public void execute() throws Exception {
ensureArgCount(2);
final String containerId = getArg(0);
final String segmentStoreHost = getArg(1);
@Cleanup CuratorFramework zkClient = createZKClient();
@Cleanup AdminSegmentHelper adminSegmentHelper = instantiateAdminSegmentHelper(zkClient);
if (containerId.equalsIgnoreCase(ALL_CONTAINERS)) {
int containerCount = getServiceConfig().getContainerCount();
for (int id = 0; id < containerCount; id++) {
flushContainerToStorage(adminSegmentHelper, id, segmentStoreHost);
}
} else {
flushContainerToStorage(adminSegmentHelper, parseInt(containerId), segmentStoreHost);
}
}
use of io.pravega.cli.admin.utils.AdminSegmentHelper in project pravega by pravega.
the class ListChunksCommand method execute.
@Override
public void execute() {
ensureArgCount(2);
final String fullyQualifiedSegmentName = getArg(0);
final String segmentStoreHost = getArg(1);
@Cleanup CuratorFramework zkClient = createZKClient();
@Cleanup AdminSegmentHelper adminSegmentHelper = instantiateAdminSegmentHelper(zkClient);
CompletableFuture<WireCommands.StorageChunksListed> reply = adminSegmentHelper.listStorageChunks(fullyQualifiedSegmentName, new PravegaNodeUri(segmentStoreHost, getServiceConfig().getAdminGatewayPort()), super.authHelper.retrieveMasterToken());
List<WireCommands.ChunkInfo> chunks = reply.join().getChunks();
output("List of chunks for %s: ", fullyQualifiedSegmentName);
chunks.forEach(chunk -> {
output("- Chunk name = %s", chunk.getChunkName());
CHUNK_INFO_FIELD_MAP.forEach((name, f) -> output(" %s = %s", name, f.apply(chunk)));
output("");
});
}
use of io.pravega.cli.admin.utils.AdminSegmentHelper in project pravega by pravega.
the class GetTableSegmentEntryCommand method execute.
@Override
public void execute() {
ensureArgCount(3);
ensureSerializersExist();
final String fullyQualifiedTableSegmentName = getArg(0);
final String key = getArg(1);
final String segmentStoreHost = getArg(2);
@Cleanup CuratorFramework zkClient = createZKClient();
@Cleanup AdminSegmentHelper adminSegmentHelper = instantiateAdminSegmentHelper(zkClient);
String value = getTableEntry(fullyQualifiedTableSegmentName, key, segmentStoreHost, adminSegmentHelper);
output("For the given key: %s", key);
userFriendlyOutput(value);
}
Aggregations