@Test public void testLocateExternalResourceName() { String clusterName = "clustername"; String keyspace = "keyspace"; CassandraExternalResourceAnalyzer resourceAnalyzer = CassandraExternalResourceAnalyzer.getInstance(); Operation op = createOperation(CassandraExternalResourceAnalyzer.TYPE, keyspace, clusterName, 1234, "127.0.0.1", "128.0.0.1"); Frame frame = createFrame(op); Trace trace = createTrace(frame); Collection<ExternalResourceDescriptor> externalResourceDescriptors = resourceAnalyzer.locateExternalResourceName(trace, Collections.singletonList(frame)); assertNotNull(externalResourceDescriptors); assertEquals("One external resource", 1, externalResourceDescriptors.size()); ExternalResourceDescriptor descriptor = externalResourceDescriptors.iterator().next(); assertNotNull(descriptor.getFrame()); assertFalse(descriptor.isIncoming()); assertEquals(descriptor.getType(), ExternalResourceType.MAPSTORE.toString()); assertEquals("External resource name", CassandraExternalResourceAnalyzer.VENDOR + ":" + clusterName + ":" + keyspace, descriptor.getName()); assertEquals("port", 1234, descriptor.getPort()); assertEquals("host", clusterName, descriptor.getHost()); }
public Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String clusterName = op.get(CassandraOperationFinalizer.CLUSTER_NAME, String.class); String keyspace = op.get(CassandraOperationFinalizer.KEYSPACE, String.class); int port = op.getInt(CassandraOperationFinalizer.PORT, -1); OperationList hosts = op.get(CassandraOperationFinalizer.HOSTS, OperationList.class); dbDescriptors.add(getDescriptor(dbFrame, hosts, port, clusterName, keyspace)); } return dbDescriptors; }
CassandraExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String clusterName = op.get(CassandraOperationFinalizer.CLUSTER_NAME, String.class); String keyspace = op.get(CassandraOperationFinalizer.KEYSPACE, String.class); int port = op.getInt(CassandraOperationFinalizer.PORT, -1); OperationList hosts = op.get(CassandraOperationFinalizer.HOSTS, OperationList.class); dbDescriptors.add(getDescriptor(dbFrame, hosts, port, clusterName, keyspace)); } return dbDescriptors; } }
CassandraExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String clusterName = op.get(CassandraOperationFinalizer.CLUSTER_NAME, String.class); String keyspace = op.get(CassandraOperationFinalizer.KEYSPACE, String.class); int port = op.getInt(CassandraOperationFinalizer.PORT, -1); OperationList hosts = op.get(CassandraOperationFinalizer.HOSTS, OperationList.class); dbDescriptors.add(getDescriptor(dbFrame, hosts, port, clusterName, keyspace)); } return dbDescriptors; } private  CassandraExternalResourceAnalyzer();   CassandraExternalResourceAnalyzer(OperationType type); }
CassandraExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String clusterName = op.get(CassandraOperationFinalizer.CLUSTER_NAME, String.class); String keyspace = op.get(CassandraOperationFinalizer.KEYSPACE, String.class); int port = op.getInt(CassandraOperationFinalizer.PORT, -1); OperationList hosts = op.get(CassandraOperationFinalizer.HOSTS, OperationList.class); dbDescriptors.add(getDescriptor(dbFrame, hosts, port, clusterName, keyspace)); } return dbDescriptors; } private  CassandraExternalResourceAnalyzer();   CassandraExternalResourceAnalyzer(OperationType type); static final CassandraExternalResourceAnalyzer getInstance(); Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames); }
CassandraExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String clusterName = op.get(CassandraOperationFinalizer.CLUSTER_NAME, String.class); String keyspace = op.get(CassandraOperationFinalizer.KEYSPACE, String.class); int port = op.getInt(CassandraOperationFinalizer.PORT, -1); OperationList hosts = op.get(CassandraOperationFinalizer.HOSTS, OperationList.class); dbDescriptors.add(getDescriptor(dbFrame, hosts, port, clusterName, keyspace)); } return dbDescriptors; } private  CassandraExternalResourceAnalyzer();   CassandraExternalResourceAnalyzer(OperationType type); static final CassandraExternalResourceAnalyzer getInstance(); Collection<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames); static final OperationType TYPE; static final String VENDOR; static final String DEFAULT_CLUSTER_NAME; static final String DEFAULT_KEYSPACE_NAME; }