@Test public void getSchemaRegistryResources() throws Exception { String serviceName = "schema-registry"; Map<String, String> configs = new HashMap<>(); configs.put("schema.registry.url", "http: AutocompletionAgent client = new TestAutocompletionAgent("schema-registry", configs); ResourceLookupContext lookupContext = new ResourceLookupContext(); lookupContext.setResources(new HashMap<>()); List<String> groups = new ArrayList<>(), schemas = new ArrayList<>(), branches = new ArrayList<>(); groups.add("Group1"); schemas.add("Schema1"); branches.add("Branch1"); lookupContext.getResources().put("schema-group", groups); lookupContext.getResources().put("schema-metadata", schemas); lookupContext.getResources().put("schema-branch", branches); lookupContext.setResourceName("schema-group"); lookupContext.setUserInput("test"); List<String> res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); List<String> expected = new ArrayList<>(); expected.add("Group1"); expected.add("testGroup"); assertThat(res, is(expected)); lookupContext.setResourceName("schema-metadata"); lookupContext.setUserInput("testS"); res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); expected = new ArrayList<>(); expected.add("Schema1"); expected.add("testSchema"); assertThat(res, is(expected)); lookupContext.setResourceName("schema-branch"); lookupContext.setUserInput("testB"); res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); expected = new ArrayList<>(); expected.add("Branch1"); expected.add("testBranch"); assertThat(res, is(expected)); lookupContext.setResourceName("schema-version"); lookupContext.setUserInput("*"); res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); expected = new ArrayList<>(); expected.add("*"); assertThat(res, is(expected)); lookupContext.setResourceName("serde"); res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); assertThat(res, is(expected)); lookupContext.setResourceName("registry-service"); res = SchemaRegistryResourceMgr.getSchemaRegistryResources(serviceName, configs, lookupContext, client); assertThat(res, is(expected)); }
public static List<String> getSchemaRegistryResources(String serviceName, Map<String, String> configs, ResourceLookupContext context, AutocompletionAgent registryClient) throws Exception { String userInput = context.getUserInput(); String resource = context.getResourceName(); Map<String, List<String>> resourceMap = context.getResources(); List<String> resultList = null; if (LOG.isDebugEnabled()) { LOG.debug("==> SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap); } if (userInput != null && !userInput.isEmpty() && serviceName != null && resource != null && resourceMap != null && !resourceMap.isEmpty()) { if (registryClient != null) { Callable<List<String>> callableObj = null; try { switch (resource.trim().toLowerCase()) { case SCHEMA_GROUP: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); final String finalSchemaGroupName = userInput; callableObj = () -> registryClient.getSchemaGroupList(finalSchemaGroupName, schemaGroupList); break; } case SCHEMA_METADATA: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); final String finalSchemaName = userInput; callableObj = () -> registryClient.getSchemaMetadataList(finalSchemaName, schemaGroupList, schemaMeatadataList); break; } case SCHEMA_BRANCH: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); List<String> branchList = resourceMap.get(SCHEMA_BRANCH); final String finalBranchName = userInput; callableObj = () -> registryClient.getBranchList(finalBranchName, schemaGroupList, schemaMeatadataList, branchList); break; } case SCHEMA_VERSION: case SERDE: case REGISTRY_SERVICE: { return asteriskList; } default: break; } } catch (Exception e) { LOG.error("Unable to get Schema Registry resources.", e); throw e; } if (callableObj != null) { synchronized (registryClient) { resultList = TimedEventUtil.timedTask(callableObj, LOOKUP_TIMEOUT_SEC, TimeUnit.SECONDS); } } else { LOG.error("Could not initiate at timedTask"); } } } if(LOG.isDebugEnabled()) { LOG.debug("<== SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: " + userInput + " configs: " + configs + "Result :" + resultList ); } return resultList; }
SchemaRegistryResourceMgr { public static List<String> getSchemaRegistryResources(String serviceName, Map<String, String> configs, ResourceLookupContext context, AutocompletionAgent registryClient) throws Exception { String userInput = context.getUserInput(); String resource = context.getResourceName(); Map<String, List<String>> resourceMap = context.getResources(); List<String> resultList = null; if (LOG.isDebugEnabled()) { LOG.debug("==> SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap); } if (userInput != null && !userInput.isEmpty() && serviceName != null && resource != null && resourceMap != null && !resourceMap.isEmpty()) { if (registryClient != null) { Callable<List<String>> callableObj = null; try { switch (resource.trim().toLowerCase()) { case SCHEMA_GROUP: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); final String finalSchemaGroupName = userInput; callableObj = () -> registryClient.getSchemaGroupList(finalSchemaGroupName, schemaGroupList); break; } case SCHEMA_METADATA: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); final String finalSchemaName = userInput; callableObj = () -> registryClient.getSchemaMetadataList(finalSchemaName, schemaGroupList, schemaMeatadataList); break; } case SCHEMA_BRANCH: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); List<String> branchList = resourceMap.get(SCHEMA_BRANCH); final String finalBranchName = userInput; callableObj = () -> registryClient.getBranchList(finalBranchName, schemaGroupList, schemaMeatadataList, branchList); break; } case SCHEMA_VERSION: case SERDE: case REGISTRY_SERVICE: { return asteriskList; } default: break; } } catch (Exception e) { LOG.error("Unable to get Schema Registry resources.", e); throw e; } if (callableObj != null) { synchronized (registryClient) { resultList = TimedEventUtil.timedTask(callableObj, LOOKUP_TIMEOUT_SEC, TimeUnit.SECONDS); } } else { LOG.error("Could not initiate at timedTask"); } } } if(LOG.isDebugEnabled()) { LOG.debug("<== SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: " + userInput + " configs: " + configs + "Result :" + resultList ); } return resultList; } }
SchemaRegistryResourceMgr { public static List<String> getSchemaRegistryResources(String serviceName, Map<String, String> configs, ResourceLookupContext context, AutocompletionAgent registryClient) throws Exception { String userInput = context.getUserInput(); String resource = context.getResourceName(); Map<String, List<String>> resourceMap = context.getResources(); List<String> resultList = null; if (LOG.isDebugEnabled()) { LOG.debug("==> SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap); } if (userInput != null && !userInput.isEmpty() && serviceName != null && resource != null && resourceMap != null && !resourceMap.isEmpty()) { if (registryClient != null) { Callable<List<String>> callableObj = null; try { switch (resource.trim().toLowerCase()) { case SCHEMA_GROUP: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); final String finalSchemaGroupName = userInput; callableObj = () -> registryClient.getSchemaGroupList(finalSchemaGroupName, schemaGroupList); break; } case SCHEMA_METADATA: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); final String finalSchemaName = userInput; callableObj = () -> registryClient.getSchemaMetadataList(finalSchemaName, schemaGroupList, schemaMeatadataList); break; } case SCHEMA_BRANCH: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); List<String> branchList = resourceMap.get(SCHEMA_BRANCH); final String finalBranchName = userInput; callableObj = () -> registryClient.getBranchList(finalBranchName, schemaGroupList, schemaMeatadataList, branchList); break; } case SCHEMA_VERSION: case SERDE: case REGISTRY_SERVICE: { return asteriskList; } default: break; } } catch (Exception e) { LOG.error("Unable to get Schema Registry resources.", e); throw e; } if (callableObj != null) { synchronized (registryClient) { resultList = TimedEventUtil.timedTask(callableObj, LOOKUP_TIMEOUT_SEC, TimeUnit.SECONDS); } } else { LOG.error("Could not initiate at timedTask"); } } } if(LOG.isDebugEnabled()) { LOG.debug("<== SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: " + userInput + " configs: " + configs + "Result :" + resultList ); } return resultList; }  }
SchemaRegistryResourceMgr { public static List<String> getSchemaRegistryResources(String serviceName, Map<String, String> configs, ResourceLookupContext context, AutocompletionAgent registryClient) throws Exception { String userInput = context.getUserInput(); String resource = context.getResourceName(); Map<String, List<String>> resourceMap = context.getResources(); List<String> resultList = null; if (LOG.isDebugEnabled()) { LOG.debug("==> SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap); } if (userInput != null && !userInput.isEmpty() && serviceName != null && resource != null && resourceMap != null && !resourceMap.isEmpty()) { if (registryClient != null) { Callable<List<String>> callableObj = null; try { switch (resource.trim().toLowerCase()) { case SCHEMA_GROUP: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); final String finalSchemaGroupName = userInput; callableObj = () -> registryClient.getSchemaGroupList(finalSchemaGroupName, schemaGroupList); break; } case SCHEMA_METADATA: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); final String finalSchemaName = userInput; callableObj = () -> registryClient.getSchemaMetadataList(finalSchemaName, schemaGroupList, schemaMeatadataList); break; } case SCHEMA_BRANCH: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); List<String> branchList = resourceMap.get(SCHEMA_BRANCH); final String finalBranchName = userInput; callableObj = () -> registryClient.getBranchList(finalBranchName, schemaGroupList, schemaMeatadataList, branchList); break; } case SCHEMA_VERSION: case SERDE: case REGISTRY_SERVICE: { return asteriskList; } default: break; } } catch (Exception e) { LOG.error("Unable to get Schema Registry resources.", e); throw e; } if (callableObj != null) { synchronized (registryClient) { resultList = TimedEventUtil.timedTask(callableObj, LOOKUP_TIMEOUT_SEC, TimeUnit.SECONDS); } } else { LOG.error("Could not initiate at timedTask"); } } } if(LOG.isDebugEnabled()) { LOG.debug("<== SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: " + userInput + " configs: " + configs + "Result :" + resultList ); } return resultList; }  static List<String> getSchemaRegistryResources(String serviceName,
                                                          Map<String, String> configs,
                                                          ResourceLookupContext context,
                                                          AutocompletionAgent registryClient); }
SchemaRegistryResourceMgr { public static List<String> getSchemaRegistryResources(String serviceName, Map<String, String> configs, ResourceLookupContext context, AutocompletionAgent registryClient) throws Exception { String userInput = context.getUserInput(); String resource = context.getResourceName(); Map<String, List<String>> resourceMap = context.getResources(); List<String> resultList = null; if (LOG.isDebugEnabled()) { LOG.debug("==> SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap); } if (userInput != null && !userInput.isEmpty() && serviceName != null && resource != null && resourceMap != null && !resourceMap.isEmpty()) { if (registryClient != null) { Callable<List<String>> callableObj = null; try { switch (resource.trim().toLowerCase()) { case SCHEMA_GROUP: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); final String finalSchemaGroupName = userInput; callableObj = () -> registryClient.getSchemaGroupList(finalSchemaGroupName, schemaGroupList); break; } case SCHEMA_METADATA: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); final String finalSchemaName = userInput; callableObj = () -> registryClient.getSchemaMetadataList(finalSchemaName, schemaGroupList, schemaMeatadataList); break; } case SCHEMA_BRANCH: { List<String> schemaGroupList = resourceMap.get(SCHEMA_GROUP); List<String> schemaMeatadataList = resourceMap.get(SCHEMA_METADATA); List<String> branchList = resourceMap.get(SCHEMA_BRANCH); final String finalBranchName = userInput; callableObj = () -> registryClient.getBranchList(finalBranchName, schemaGroupList, schemaMeatadataList, branchList); break; } case SCHEMA_VERSION: case SERDE: case REGISTRY_SERVICE: { return asteriskList; } default: break; } } catch (Exception e) { LOG.error("Unable to get Schema Registry resources.", e); throw e; } if (callableObj != null) { synchronized (registryClient) { resultList = TimedEventUtil.timedTask(callableObj, LOOKUP_TIMEOUT_SEC, TimeUnit.SECONDS); } } else { LOG.error("Could not initiate at timedTask"); } } } if(LOG.isDebugEnabled()) { LOG.debug("<== SchemaRegistryResourceMgr.getSchemaRegistryResources() UserInput: " + userInput + " configs: " + configs + "Result :" + resultList ); } return resultList; }  static List<String> getSchemaRegistryResources(String serviceName,
                                                          Map<String, String> configs,
                                                          ResourceLookupContext context,
                                                          AutocompletionAgent registryClient);  }