use of co.cask.cdap.proto.NamespaceMeta in project cdap by caskdata.
the class SparkTestRun method testScalaSparkCrossNSDataset.
@Test
public void testScalaSparkCrossNSDataset() throws Exception {
// Deploy and create a dataset in namespace datasetSpaceForSpark
NamespaceMeta inputDSNSMeta = new NamespaceMeta.Builder().setName("datasetSpaceForSpark").build();
getNamespaceAdmin().create(inputDSNSMeta);
deploy(inputDSNSMeta.getNamespaceId(), SparkAppUsingObjectStore.class);
DataSetManager<ObjectStore<String>> keysManager = getDataset(inputDSNSMeta.getNamespaceId().dataset("keys"));
prepareInputData(keysManager);
Map<String, String> args = ImmutableMap.of(ScalaCharCountProgram.INPUT_DATASET_NAMESPACE(), inputDSNSMeta.getNamespaceId().getNamespace(), ScalaCharCountProgram.INPUT_DATASET_NAME(), "keys");
ApplicationManager applicationManager = deploy(SparkAppUsingObjectStore.class);
SparkManager sparkManager = applicationManager.getSparkManager(ScalaCharCountProgram.class.getSimpleName()).start(args);
sparkManager.waitForRun(ProgramRunStatus.COMPLETED, 1, TimeUnit.MINUTES);
DataSetManager<KeyValueTable> countManager = getDataset("count");
checkOutputData(countManager);
}
use of co.cask.cdap.proto.NamespaceMeta in project cdap by caskdata.
the class NamespaceHttpHandler method getNamespace.
@GET
@Path("/namespaces/{namespace-id}")
public void getNamespace(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception {
NamespaceMeta ns = namespaceAdmin.get(new NamespaceId(namespaceId));
responder.sendJson(HttpResponseStatus.OK, ns);
}
use of co.cask.cdap.proto.NamespaceMeta in project cdap by caskdata.
the class NamespaceHttpHandler method create.
@PUT
@Path("/namespaces/{namespace-id}")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void create(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception {
Id.Namespace namespace;
try {
namespace = Id.Namespace.from(namespaceId);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Namespace id can contain only alphanumeric characters or '_'.");
}
NamespaceMeta metadata = getNamespaceMeta(request);
if (isReserved(namespaceId)) {
throw new BadRequestException(String.format("Cannot create the namespace '%s'. '%s' is a reserved namespace.", namespaceId, namespaceId));
}
NamespaceMeta.Builder builder = metadata == null ? new NamespaceMeta.Builder() : new NamespaceMeta.Builder(metadata);
builder.setName(namespace);
NamespaceMeta finalMetadata = builder.build();
try {
namespaceAdmin.create(finalMetadata);
responder.sendString(HttpResponseStatus.OK, String.format("Namespace '%s' created successfully.", namespaceId));
} catch (AlreadyExistsException e) {
responder.sendString(HttpResponseStatus.OK, String.format("Namespace '%s' already exists.", namespaceId));
}
}
use of co.cask.cdap.proto.NamespaceMeta in project cdap by caskdata.
the class NamespaceHttpHandler method updateNamespaceProperties.
@PUT
@Path("/namespaces/{namespace-id}/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void updateNamespaceProperties(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception {
NamespaceMeta meta = getNamespaceMeta(request);
namespaceAdmin.updateProperties(new NamespaceId(namespaceId), meta);
responder.sendString(HttpResponseStatus.OK, String.format("Updated properties for namespace '%s'.", namespaceId));
}
use of co.cask.cdap.proto.NamespaceMeta in project cdap by caskdata.
the class UpgradeTool method upgrade.
private Set<ApplicationId> upgrade() throws Exception {
Set<ApplicationId> upgraded = new HashSet<>();
for (NamespaceMeta namespaceMeta : namespaceClient.list()) {
NamespaceId namespace = new NamespaceId(namespaceMeta.getName());
upgraded.addAll(upgrade(namespace));
}
return upgraded;
}
Aggregations