@Override void perform() throws IOException { NamespaceDescriptor selected = selectNamespace(namespaceMap); if (selected == null) { return; } Admin admin = connection.getAdmin(); try { String namespaceName = selected.getName(); LOG.info("Deleting namespace :" + selected); admin.deleteNamespace(namespaceName); try { if (admin.getNamespaceDescriptor(namespaceName) != null) { // the namespace still exists. Assert.assertTrue("Namespace: " + selected + " was not deleted", false); } else { LOG.info("Deleted namespace :" + selected); } } catch (NamespaceNotFoundException nsnfe) { // This is expected result LOG.info("Deleted namespace :" + selected); } } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
@Override void perform() throws IOException { NamespaceDescriptor selected = selectNamespace(namespaceMap); if (selected == null) { return; } Admin admin = connection.getAdmin(); try { String namespaceName = selected.getName(); LOG.info("Modifying namespace :" + selected); NamespaceDescriptor modifiedNsd = NamespaceDescriptor.create(namespaceName).build(); String nsValueNew; do { nsValueNew = String.format("%010d", RandomUtils.nextInt(Integer.MAX_VALUE)); } while (selected.getConfigurationValue(nsTestConfigKey).equals(nsValueNew)); modifiedNsd.setConfiguration(nsTestConfigKey, nsValueNew); admin.modifyNamespace(modifiedNsd); NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(namespaceName); Assert.assertTrue( "Namespace: " + selected + " was not modified", freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew)); LOG.info("Modified namespace :" + freshNamespaceDesc); namespaceMap.put(namespaceName, freshNamespaceDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
@Override void perform() throws IOException { Admin admin = connection.getAdmin(); try { NamespaceDescriptor nsd; while (true) { nsd = createNamespaceDesc(); try { if (admin.getNamespaceDescriptor(nsd.getName()) != null) { // the namespace has already existed. continue; } else { // currently, the code never return null - always throws exception if // namespace is not found - this just a defensive programming to make // sure null situation is handled in case the method changes in the // future. break; } } catch (NamespaceNotFoundException nsnfe) { // This is expected for a random generated NamespaceDescriptor break; } } LOG.info("Creating namespace:" + nsd); admin.createNamespace(nsd); NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(nsd.getName()); Assert.assertTrue("Namespace: " + nsd + " was not created", freshNamespaceDesc != null); LOG.info("Created namespace:" + freshNamespaceDesc); namespaceMap.put(nsd.getName(), freshNamespaceDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyNamespaces(); }
protected void verifyNamespaces() throws IOException { Connection connection = getConnection(); Admin admin = connection.getAdmin(); // iterating concurrent map for (String nsName : namespaceMap.keySet()) { try { Assert.assertTrue( "Namespace: " + nsName + " in namespaceMap does not exist", admin.getNamespaceDescriptor(nsName) != null); } catch (NamespaceNotFoundException nsnfe) { Assert.fail( "Namespace: " + nsName + " in namespaceMap does not exist: " + nsnfe.getMessage()); } } admin.close(); }