@Test public void testListFunctions() throws PulsarClientException { FunctionMetaDataManager functionMetaDataManager = spy( new FunctionMetaDataManager(new WorkerConfig(), mock(SchedulerManager.class), mockPulsarClient(), ErrorNotifier.getDefaultImpl())); Map<String, Function.FunctionMetaData> functionMetaDataMap1 = new HashMap<>(); Function.FunctionMetaData f1 = Function.FunctionMetaData.newBuilder().setFunctionDetails( Function.FunctionDetails.newBuilder().setName("func-1")).build(); functionMetaDataMap1.put("func-1", f1); Function.FunctionMetaData f2 = Function.FunctionMetaData.newBuilder().setFunctionDetails( Function.FunctionDetails.newBuilder().setName("func-2")).build(); functionMetaDataMap1.put("func-2", f2); Function.FunctionMetaData f3 = Function.FunctionMetaData.newBuilder().setFunctionDetails( Function.FunctionDetails.newBuilder().setName("func-3")).build(); Map<String, Function.FunctionMetaData> functionMetaDataInfoMap2 = new HashMap<>(); functionMetaDataInfoMap2.put("func-3", f3); functionMetaDataManager.functionMetaDataMap.put("tenant-1", new HashMap<>()); functionMetaDataManager.functionMetaDataMap.get("tenant-1").put("namespace-1", functionMetaDataMap1); functionMetaDataManager.functionMetaDataMap.get("tenant-1").put("namespace-2", functionMetaDataInfoMap2); Assert.assertEquals(0, functionMetaDataManager.listFunctions( "tenant", "namespace").size()); Assert.assertEquals(2, functionMetaDataManager.listFunctions( "tenant-1", "namespace-1").size()); Assert.assertTrue(functionMetaDataManager.listFunctions( "tenant-1", "namespace-1").contains(f1)); Assert.assertTrue(functionMetaDataManager.listFunctions( "tenant-1", "namespace-1").contains(f2)); Assert.assertEquals(1, functionMetaDataManager.listFunctions( "tenant-1", "namespace-2").size()); Assert.assertTrue(functionMetaDataManager.listFunctions( "tenant-1", "namespace-2").contains(f3)); }
public synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace) { List<FunctionMetaData> ret = new LinkedList<>(); if (!this.functionMetaDataMap.containsKey(tenant)) { return ret; } if (!this.functionMetaDataMap.get(tenant).containsKey(namespace)) { return ret; } for (FunctionMetaData functionMetaData : this.functionMetaDataMap.get(tenant).get(namespace).values()) { ret.add(functionMetaData); } return ret; }
FunctionMetaDataManager implements AutoCloseable { public synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace) { List<FunctionMetaData> ret = new LinkedList<>(); if (!this.functionMetaDataMap.containsKey(tenant)) { return ret; } if (!this.functionMetaDataMap.get(tenant).containsKey(namespace)) { return ret; } for (FunctionMetaData functionMetaData : this.functionMetaDataMap.get(tenant).get(namespace).values()) { ret.add(functionMetaData); } return ret; } }
FunctionMetaDataManager implements AutoCloseable { public synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace) { List<FunctionMetaData> ret = new LinkedList<>(); if (!this.functionMetaDataMap.containsKey(tenant)) { return ret; } if (!this.functionMetaDataMap.get(tenant).containsKey(namespace)) { return ret; } for (FunctionMetaData functionMetaData : this.functionMetaDataMap.get(tenant).get(namespace).values()) { ret.add(functionMetaData); } return ret; } FunctionMetaDataManager(WorkerConfig workerConfig,
                                   SchedulerManager schedulerManager,
                                   PulsarClient pulsarClient,
                                   ErrorNotifier errorNotifier); }
FunctionMetaDataManager implements AutoCloseable { public synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace) { List<FunctionMetaData> ret = new LinkedList<>(); if (!this.functionMetaDataMap.containsKey(tenant)) { return ret; } if (!this.functionMetaDataMap.get(tenant).containsKey(namespace)) { return ret; } for (FunctionMetaData functionMetaData : this.functionMetaDataMap.get(tenant).get(namespace).values()) { ret.add(functionMetaData); } return ret; } FunctionMetaDataManager(WorkerConfig workerConfig,
                                   SchedulerManager schedulerManager,
                                   PulsarClient pulsarClient,
                                   ErrorNotifier errorNotifier); synchronized void initialize(); synchronized void start(); @Override void close(); synchronized FunctionMetaData getFunctionMetaData(String tenant, String namespace, String functionName); synchronized List<FunctionMetaData> getAllFunctionMetaData(); synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace); synchronized boolean containsFunction(String tenant, String namespace, String functionName); synchronized void updateFunctionOnLeader(FunctionMetaData functionMetaData, boolean delete); void acquireLeadership(); synchronized void giveupLeadership(); void processMetaDataTopicMessage(Message<byte[]> message); }
FunctionMetaDataManager implements AutoCloseable { public synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace) { List<FunctionMetaData> ret = new LinkedList<>(); if (!this.functionMetaDataMap.containsKey(tenant)) { return ret; } if (!this.functionMetaDataMap.get(tenant).containsKey(namespace)) { return ret; } for (FunctionMetaData functionMetaData : this.functionMetaDataMap.get(tenant).get(namespace).values()) { ret.add(functionMetaData); } return ret; } FunctionMetaDataManager(WorkerConfig workerConfig,
                                   SchedulerManager schedulerManager,
                                   PulsarClient pulsarClient,
                                   ErrorNotifier errorNotifier); synchronized void initialize(); synchronized void start(); @Override void close(); synchronized FunctionMetaData getFunctionMetaData(String tenant, String namespace, String functionName); synchronized List<FunctionMetaData> getAllFunctionMetaData(); synchronized Collection<FunctionMetaData> listFunctions(String tenant, String namespace); synchronized boolean containsFunction(String tenant, String namespace, String functionName); synchronized void updateFunctionOnLeader(FunctionMetaData functionMetaData, boolean delete); void acquireLeadership(); synchronized void giveupLeadership(); void processMetaDataTopicMessage(Message<byte[]> message);  }