Package com.aphyr.riemann.client

Examples of com.aphyr.riemann.client.RiemannClient


public class TcpClientTest {
  @Test
  public void sendEventsTest() throws IOException, InterruptedException, ServerError {
    final Server server = new OkServer();
    RiemannClient client = null;
    try {
      client = RiemannClient.tcp(server.start());
      client.connect();
      for (int i = 0; i < 10; i++) {
        final Event e = Util.createEvent();
        assertEquals(true, client.sendEventsWithAck(e));
        assertEquals(e, Util.soleEvent(server.received.poll()));
      }
    } finally {
      if (client != null) {
        client.disconnect();
      }
      server.stop();
    }
  }
View Full Code Here


  }

  @Test
  public void queryTest() throws IOException, InterruptedException, ServerError {
    final Server server = new EchoServer();
    RiemannClient client = null;
    try {
      client = RiemannClient.tcp(server.start());
      client.connect();
      for (int i = 0; i < 10; i++) {
        final List<Event> events = client.query("hi");
        assertEquals(0, events.size());
        final Msg m = server.received.poll();
        assertEquals("hi", m.getQuery().getString());
      }
    } finally {
      if (client != null) {
        client.disconnect();
      }
      server.stop();
    }
  }
View Full Code Here

public class SimpleUdpClientTest {
  @Test
  public void sendEventsTest() throws IOException, InterruptedException, ServerError {
    final DatagramSocket serverSocket = new DatagramSocket();
    try {
      final RiemannClient client = new RiemannClient(new SimpleUdpTransport(serverSocket.getLocalPort()));
      try {
        client.connect();
        sendTestMessages(serverSocket, client);
      } finally {
        client.disconnect();
      }
    } finally {
      serverSocket.close();
    }
  }
View Full Code Here

  @Test
  public void sendEventsOverReconnectionTest() throws IOException, InterruptedException, ServerError {
    DatagramSocket serverSocket = new DatagramSocket();
    final int port = serverSocket.getLocalPort();
    try {
      final RiemannClient client = new RiemannClient(new SimpleUdpTransport(serverSocket.getLocalPort()));
      try {
        client.connect();
        assertTrue(client.isConnected());
        sendTestMessages(serverSocket, client);

        // Close listening socket
        serverSocket.close();

        // Expect send to drop messages silently
        final Proto.Event e = Util.createEvent();
        client.sendEvents(e);

        // Reopen listening socket
        serverSocket = new DatagramSocket(new InetSocketAddress(port));

        // Expect sent messages to be received again
        sendTestMessages(serverSocket, client);

      } finally {
        client.disconnect();
        assertFalse(client.isConnected());
      }
    } finally {
      serverSocket.close();
    }
  }
View Full Code Here

    public Riemann(String host, Integer port, int batchSize) throws IOException {
        this(getClient(host, port, batchSize));
    }

    private static AbstractRiemannClient getClient(String host, Integer port, int batchSize) throws IOException {
        RiemannClient c = RiemannClient.tcp(host, port);
        try {
            return new RiemannBatchClient(batchSize, c);
        } catch (UnsupportedJVMException e) {
            return c;
        }
View Full Code Here

        this.jmxUsername = jmxUsername;
        this.jmxPassword = jmxPassword;

        this.protoEvent = Proto.Event.newBuilder().setHost(pickBestHostname(cassandraHost)).addTags("cassandra").setState("ok").setTtl(5.0F).build();

        this.riemannClient = new RiemannClient(new InetSocketAddress(riemannHost, riemannPort.intValue()));
        if (!reconnectJMX()) {
            System.err.println(String.format("Unable to connect to Cassandra JMX (%s:%d) will continue to try silently....", new Object[] { cassandraHost, cassandraJmxPort }));
        }
    }
View Full Code Here

    host = Iterables.get(parts, size - 2);
    port = Integer.valueOf(Iterables.get(parts, size - 1));
  }

  public RiemannFacade getFacade() {
    final RiemannClient cli = getClient();
    if (cli == null) {
      return new NoOpRiemannClient().facade();
    }
    return new RiemannFacade(cli, hostName, serviceName);
  }
View Full Code Here

TOP

Related Classes of com.aphyr.riemann.client.RiemannClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.