@GET @Path("/namespaces") public void getAllNamespaces(HttpRequest request, HttpResponder responder) throws Exception { // return keytab URI without version responder.sendJson(HttpResponseStatus.OK, GSON.toJson(namespaceAdmin.list().stream() .map(meta -> new NamespaceMeta.Builder(meta).buildWithoutKeytabURIVersion()) .collect(Collectors.toList()))); }
@GET @Path("/namespaces") public void getAllNamespaces(HttpRequest request, HttpResponder responder) throws Exception { // return keytab URI without version responder.sendJson(HttpResponseStatus.OK, GSON.toJson(namespaceAdmin.list().stream() .map(meta -> new NamespaceMeta.Builder(meta).buildWithoutKeytabURIVersion()) .collect(Collectors.toList()))); }
@GET @Path("/namespaces/{namespace-id}") public void getNamespace(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception { // return keytab URI without version NamespaceMeta ns = new NamespaceMeta.Builder(namespaceAdmin.get(new NamespaceId(namespaceId))).buildWithoutKeytabURIVersion(); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(ns)); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { String name = arguments.get(ArgumentName.NAMESPACE_NAME.toString()); String description = arguments.getOptional(ArgumentName.DESCRIPTION.toString(), null); String principal = arguments.getOptional(ArgumentName.PRINCIPAL.toString(), null); String groupName = arguments.getOptional(ArgumentName.NAMESPACE_GROUP_NAME.toString(), null); String keytabPath = arguments.getOptional(ArgumentName.NAMESPACE_KEYTAB_PATH.toString(), null); String hbaseNamespace = arguments.getOptional(ArgumentName.NAMESPACE_HBASE_NAMESPACE.toString(), null); String hiveDatabase = arguments.getOptional(ArgumentName.NAMESPACE_HIVE_DATABASE.toString(), null); String schedulerQueueName = arguments.getOptional(ArgumentName.NAMESPACE_SCHEDULER_QUEUENAME.toString(), null); String rootDir = arguments.getOptional(ArgumentName.NAMESPACE_ROOT_DIR.toString(), null); String exploreAsPrinc = arguments.getOptional(ArgumentName.NAMESPACE_EXPLORE_AS_PRINCIPAL.toString(), "true"); Boolean exploreAsPrincipal = Boolean.valueOf(exploreAsPrinc); NamespaceMeta.Builder builder = new NamespaceMeta.Builder(); builder.setName(name).setDescription(description).setPrincipal(principal).setGroupName(groupName) .setKeytabURI(keytabPath).setRootDirectory(rootDir).setHBaseNamespace(hbaseNamespace) .setHiveDatabase(hiveDatabase).setSchedulerQueueName(schedulerQueueName) .setExploreAsPrincipal(exploreAsPrincipal); namespaceClient.create(builder.build()); output.println(String.format(SUCCESS_MSG, name)); }
@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(NamespaceId.DEFAULT, SparkAppUsingObjectStore.class); SparkManager sparkManager = applicationManager.getSparkManager(ScalaCharCountProgram.class.getSimpleName()).start(args); sparkManager.waitForRun(ProgramRunStatus.RUNNING, 10, TimeUnit.SECONDS); sparkManager.waitForStopped(60, TimeUnit.SECONDS); DataSetManager<KeyValueTable> countManager = getDataset("count"); checkOutputData(countManager); }
@Before public void setUp() throws Exception { CConfiguration conf = CConfiguration.create(); conf.set(Constants.Security.Store.FILE_PATH, TEMP_FOLDER.newFolder().getAbsolutePath()); SConfiguration sConf = SConfiguration.create(); sConf.set(Constants.Security.Store.FILE_PASSWORD, "secret"); InMemoryNamespaceAdmin namespaceClient = new InMemoryNamespaceAdmin(); NamespaceMeta namespaceMeta = new NamespaceMeta.Builder() .setName(NAMESPACE1) .build(); namespaceClient.create(namespaceMeta); namespaceMeta = new NamespaceMeta.Builder() .setName(NAMESPACE2) .build(); namespaceClient.create(namespaceMeta); FileSecureStoreService fileSecureStoreService = new FileSecureStoreService(conf, sConf, namespaceClient); secureStoreManager = fileSecureStoreService; secureStore = fileSecureStoreService; }
@Before public void setUp() throws Exception { LOG.info("Beginning setUp."); checkSystemServices(); assertUnrecoverableResetEnabled(); boolean deleteUponTeardown = false; if (!getNamespaceClient().exists(configuredNamespace)) { getNamespaceClient().create(new NamespaceMeta.Builder().setName(configuredNamespace).build()); // if we created the configured namespace, delete it upon teardown deleteUponTeardown = true; } else { // only need to clear the namespace if it already existed doClear(configuredNamespace, false); } registeredNamespaces.put(configuredNamespace, deleteUponTeardown); LOG.info("Completed setUp."); }
@BeforeClass public static void setup() throws Exception { CConfiguration cConf = CConfiguration.create(); cConf.set(Constants.INSTANCE_NAME, EXISTS); Injector injector = AppFabricTestHelper.getInjector(cConf); NamespaceStore nsStore = injector.getInstance(NamespaceStore.class); ArtifactRepository artifactRepository = injector.getInstance(ArtifactRepository.class); cConf = injector.getInstance(CConfiguration.class); nsStore.create(new NamespaceMeta.Builder().setName(EXISTS).build()); existenceVerifier = injector.getInstance(Key.get(new TypeLiteral<EntityExistenceVerifier<EntityId>>() { })); LocalLocationFactory lf = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder()); File artifactFile = new File(AppJarHelper.createDeploymentJar(lf, AllProgramsApp.class).toURI()); artifactRepository.addArtifact(Id.Artifact.fromEntityId(ARTIFACT), artifactFile); AppFabricTestHelper.deployApplication(Id.Namespace.fromEntityId(NAMESPACE), AllProgramsApp.class, null, cConf); }
@Before public void setUp() throws Exception { getNamespaceAdmin().create(new NamespaceMeta.Builder().setName(testSpace).build()); }
@Before public void setUp() throws Exception { getNamespaceAdmin().create(new NamespaceMeta.Builder().setName(testSpace).build()); }
private static void ensureNamespaceExists(NamespaceId namespaceId, CConfiguration cConf) throws Exception { NamespaceAdmin namespaceAdmin = getInjector(cConf).getInstance(NamespaceAdmin.class); try { if (!namespaceAdmin.exists(namespaceId)) { namespaceAdmin.create(new NamespaceMeta.Builder().setName(namespaceId).build()); } } catch (NamespaceAlreadyExistsException e) { // There can be race between exists() and create() call. if (!namespaceAdmin.exists(namespaceId)) { throw new IllegalStateException("Failed to create namespace " + namespaceId.getNamespace(), e); } } }
@Before public void beforeTest() throws Exception { super.beforeTest(); getNamespaceAdmin().create(new NamespaceMeta.Builder().setName(NAMESPACE).build()); getMessagingAdmin(NAMESPACE).createTopic(MessagingApp.CONTROL_TOPIC); }
@Test(timeout = 90000L) public void testSQLQuerySimpleNS() throws Exception { namespaceAdmin.create(new NamespaceMeta.Builder().setName(testSpace).build()); testSQLQuery(); namespaceAdmin.delete(testSpace); }
@GET @Path("/namespaces/{namespace-id}") public void getNamespace(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception { // return keytab URI without version NamespaceMeta ns = new NamespaceMeta.Builder(namespaceAdmin.get(new NamespaceId(namespaceId))).buildWithoutKeytabURIVersion(); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(ns)); }
@Override public NamespaceMeta get(NamespaceId namespaceId) throws Exception { return customNSMap.containsKey(namespaceId.getNamespace()) ? customNSMap.get(namespaceId.getNamespace()) : new NamespaceMeta.Builder().setName(namespaceId.getNamespace()).build(); }
private void testDeployAppWithOwner() throws Exception { NamespaceId namespaceId = new NamespaceId("appImpersonation"); NamespaceMeta nsMeta = new NamespaceMeta.Builder().setName(namespaceId.getNamespace()).build(); // grant ALICE admin on namespace and create namespace grantAndAssertSuccess(namespaceId, ALICE, EnumSet.of(Action.ADMIN)); cleanUpEntities.add(namespaceId); getNamespaceAdmin().create(nsMeta); // deploy dummy app with app impersonation deployDummyAppWithImpersonation(nsMeta, BOB.getName()); }
@BeforeClass public static void setUp() throws Exception { InMemoryNamespaceAdmin namespaceClient = new InMemoryNamespaceAdmin(); NamespaceMeta namespaceMeta = new NamespaceMeta.Builder() .setName(NAMESPACE1) .build(); namespaceClient.create(namespaceMeta); secureStoreService = new SecretManagerSecureStoreService(namespaceClient, new MockSecretManagerContext(), "mock", new MockSecretManager()); secureStoreService.startAndWait(); }
private void createNamespace(NamespaceId namespaceId) throws Exception { // since the namespace admin here is an in memory one we need to create the location explicitly namespacePathLocator.get(namespaceId).mkdirs(); // the framework.delete looks up namespace config through namespaceadmin add the meta there too. namespaceAdmin.create(new NamespaceMeta.Builder().setName(namespaceId).build()); }
@Test public void test() throws Exception { NamespaceId myspace = new NamespaceId("myspace"); NamespaceMeta myspaceMeta = new NamespaceMeta.Builder().setName(myspace.getNamespace()).build(); // the create/delete will look up meta so store that too namespaceStore.create(myspaceMeta); storageProviderNamespaceAdmin.create(myspaceMeta); Location namespaceLocation = namespacePathLocator.get(myspace); Assert.assertTrue(namespaceLocation.exists()); storageProviderNamespaceAdmin.delete(myspace); Assert.assertFalse(namespaceLocation.exists()); }
@BeforeClass public static void setup() throws Exception { NamespacePathLocator namespacePathLocator = AppFabricTestHelper.getInjector().getInstance(NamespacePathLocator.class); namespaceHomeLocation = namespacePathLocator.get(DefaultId.NAMESPACE); NamespaceAdmin namespaceAdmin = AppFabricTestHelper.getInjector().getInstance(NamespaceAdmin.class); namespaceAdmin.create(new NamespaceMeta.Builder().setName(DefaultId.NAMESPACE).build()); Locations.mkdirsIfNotExists(namespaceHomeLocation); }