private static TableId getReplicationStateTableId(HBaseTableUtil tableUtil) throws IOException { String tableName = hConf.get(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_NAME); String ns = hConf.get(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_NAMESPACE); TableId tableId = tableUtil.createHTableId( (ns != null) ? new NamespaceId(ns) : new NamespaceId(ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_DEFAULT_NAMESPACE), (tableName != null) ? tableName : ReplicationConstants.ReplicationStatusTool.REPLICATION_STATE_TABLE_DEFAULT_NAME); return tableId; }
@Override public QueryHandle call() throws Exception { return exploreService.execute(new NamespaceId(namespaceId), query, additionalSessionConf); } }, ImpersonatedOpType.EXPLORE);
/** * Returns a {@link MessagingAdmin} for the given namespace. */ protected static MessagingAdmin getMessagingAdmin(String namespace) { return getMessagingAdmin(new NamespaceId(namespace)); }
@SuppressWarnings("unused") public static NamespaceId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new NamespaceId(nextAndEnd(iterator, "namespace")); }
@GET @Path("/topics") public void listTopics(HttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace) throws Exception { responder.sendJson(HttpResponseStatus.OK, GSON.toJson( Lists.transform(messagingService.listTopics(new NamespaceId(namespace)), TOPIC_TO_NAME), TOPIC_LIST_TYPE)); }
@GET @Path("/data/modules") public void listModules(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception { responder.sendJson(HttpResponseStatus.OK, GSON.toJson(typeService.listModules(new NamespaceId(namespaceId)))); }
@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)); }
@GET @Path("/data/types/{name}") public void getTypeInfo(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String name) throws Exception { responder.sendJson(HttpResponseStatus.OK, GSON.toJson(typeService.getType(new NamespaceId(namespaceId).datasetType(name)))); } }
/** * Validates if secret manager is loaded and the provided namespace exists. */ private void validate(String namespace) throws Exception { if (secretManager == null) { throw new RuntimeException("Secret manager is either not initialized or not loaded. "); } NamespaceId namespaceId = new NamespaceId(namespace); if (!namespaceQueryAdmin.exists(namespaceId)) { throw new NamespaceNotFoundException(namespaceId); } }
@GET @Path("/topics/{topic}") public void getTopic(HttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); TopicMetadata metadata = messagingService.getTopic(topicId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(metadata.getProperties(), TOPIC_PROPERTY_TYPE)); }
private DatasetAdminImpl(DatasetContext datasetContext, String tableName, HBaseTableUtil tableUtil, Configuration hConf, CConfiguration cConf) throws IOException { this.hConf = hConf; this.cConf = cConf; this.tableUtil = tableUtil; this.tableId = tableUtil.createHTableId(new NamespaceId(datasetContext.getNamespaceId()), tableName); this.ddlExecutorFactory = new HBaseDDLExecutorFactory(cConf, hConf); }
@Override public synchronized void create(NamespaceMeta metadata) throws Exception { NamespaceId id = new NamespaceId(metadata.getName()); NamespaceMeta existing = namespaces.putIfAbsent(id, metadata); if (existing != null) { throw new NamespaceAlreadyExistsException(id); } }
private HBaseTableUtil.TableStats getTableStats(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); // todo : should support custom table-prefix TableId tableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); Map<TableId, HBaseTableUtil.TableStats> statsMap = tableUtil.getTableStats(hAdmin); return statsMap.get(tableId); } }
private TableId getTableId(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); List<TableId> tableIds = tableUtil.listTablesInNamespace(hAdmin, tableUtil.getHBaseNamespace(new NamespaceId(namespace))); for (TableId tId : tableIds) { if (tId.getTableName().endsWith(tableName)) { return tId; } } return null; }
private HTableDescriptor getTableDescriptor(String namespace, String name) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), name); return getTableUtil().getHTableDescriptor(hAdmin, hTableId); }
private void writeSome(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); try (HTable table = tableUtil.createHTable(TEST_HBASE.getConfiguration(), hTableId)) { // writing at least couple megs to reflect in "megabyte"-based metrics for (int i = 0; i < 8; i++) { Put put = new Put(Bytes.toBytes("row" + i)); put.add(Bytes.toBytes("d"), Bytes.toBytes("col" + i), new byte[1024 * 1024]); table.put(put); } } }
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()); }
private void enable(String namespace, String tableName) throws IOException { HBaseTableUtil tableUtil = getTableUtil(); TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName); TableName name = HTableNameConverter.toTableName(getPrefix(), hTableId); ddlExecutor.enableTableIfDisabled(name.getNamespaceAsString(), name.getQualifierAsString()); }
@Test public void testGeMetadata() throws Exception { TopicId topicId = new NamespaceId("ns2").topic("d"); TopicMetadata metadata = new TopicMetadata(topicId, "ttl", "100"); for (int i = 1; i <= 5; i++) { client.createTopic(metadata); TopicMetadata topicMetadata = client.getTopic(topicId); Assert.assertEquals(100, topicMetadata.getTTL()); Assert.assertEquals(i, topicMetadata.getGeneration()); client.deleteTopic(topicId); } }
@Test public void testRemoveAllApplications() { ApplicationSpecification spec = Specifications.from(new AllProgramsApp()); NamespaceId namespaceId = new NamespaceId("account1"); ApplicationId appId = namespaceId.app(spec.getName()); store.addApplication(appId, spec); Assert.assertNotNull(store.getApplication(appId)); // removing all applications store.removeAllApplications(namespaceId); Assert.assertNull(store.getApplication(appId)); }