@Test public void testLocateDatabaseURI() throws Exception { Operation op = new Operation(); op.type(RedisExternalResourceAnalyzer.TYPE); op.put("host", "localhost"); op.put("port", 6379); op.put("dbName", "dbName"); Frame frame = new SimpleFrame(FrameId.valueOf("0"), null, op, TimeRange.milliTimeRange(0, 1), Collections.<Frame>emptyList()); Trace trace = new Trace(ServerName.valueOf("fake-server"), ApplicationName.valueOf("fake-app"), new Date(), TraceId.valueOf("fake-id"), frame); List<ExternalResourceDescriptor> externalResourceDescriptors = (List<ExternalResourceDescriptor>) analyzer.locateExternalResourceName(trace); ExternalResourceDescriptor externalResourceDescriptor = externalResourceDescriptors.get(0); assertEquals(frame, externalResourceDescriptor.getFrame()); assertEquals(ExternalResourceType.KVSTORE.name(), externalResourceDescriptor.getType()); assertEquals("redis:" + MD5NameGenerator.getName("dbNamelocalhost" + 6379), externalResourceDescriptor.getName()); assertEquals("Redis", externalResourceDescriptor.getVendor()); assertEquals("dbName", externalResourceDescriptor.getLabel()); assertEquals("localhost", externalResourceDescriptor.getHost()); assertEquals(6379, externalResourceDescriptor.getPort()); assertEquals(Boolean.FALSE, Boolean.valueOf(externalResourceDescriptor.isIncoming())); }
public List<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 host = op.get("host", String.class); int port = op.getInt("port", (-1)); String color = colorManager.getColor(op); String dbName = op.get("dbName", String.class); String redisHash = MD5NameGenerator.getName(dbName + host + port); dbDescriptors.add(new ExternalResourceDescriptor(dbFrame, "redis:" + redisHash, dbName, ExternalResourceType.KVSTORE.name(), "Redis", host, port, color, false)); } return dbDescriptors; }
RedisExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public List<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 host = op.get("host", String.class); int port = op.getInt("port", (-1)); String color = colorManager.getColor(op); String dbName = op.get("dbName", String.class); String redisHash = MD5NameGenerator.getName(dbName + host + port); dbDescriptors.add(new ExternalResourceDescriptor(dbFrame, "redis:" + redisHash, dbName, ExternalResourceType.KVSTORE.name(), "Redis", host, port, color, false)); } return dbDescriptors; } }
RedisExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public List<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 host = op.get("host", String.class); int port = op.getInt("port", (-1)); String color = colorManager.getColor(op); String dbName = op.get("dbName", String.class); String redisHash = MD5NameGenerator.getName(dbName + host + port); dbDescriptors.add(new ExternalResourceDescriptor(dbFrame, "redis:" + redisHash, dbName, ExternalResourceType.KVSTORE.name(), "Redis", host, port, color, false)); } return dbDescriptors; } private  RedisExternalResourceAnalyzer(); }
RedisExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public List<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 host = op.get("host", String.class); int port = op.getInt("port", (-1)); String color = colorManager.getColor(op); String dbName = op.get("dbName", String.class); String redisHash = MD5NameGenerator.getName(dbName + host + port); dbDescriptors.add(new ExternalResourceDescriptor(dbFrame, "redis:" + redisHash, dbName, ExternalResourceType.KVSTORE.name(), "Redis", host, port, color, false)); } return dbDescriptors; } private  RedisExternalResourceAnalyzer(); static final RedisExternalResourceAnalyzer getInstance(); List<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames); }
RedisExternalResourceAnalyzer extends AbstractExternalResourceAnalyzer { public List<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 host = op.get("host", String.class); int port = op.getInt("port", (-1)); String color = colorManager.getColor(op); String dbName = op.get("dbName", String.class); String redisHash = MD5NameGenerator.getName(dbName + host + port); dbDescriptors.add(new ExternalResourceDescriptor(dbFrame, "redis:" + redisHash, dbName, ExternalResourceType.KVSTORE.name(), "Redis", host, port, color, false)); } return dbDescriptors; } private  RedisExternalResourceAnalyzer(); static final RedisExternalResourceAnalyzer getInstance(); List<ExternalResourceDescriptor> locateExternalResourceName(Trace trace, Collection<Frame> dbFrames); static final OperationType TYPE; }