summaryrefslogtreecommitdiff
path: root/statserver/src/main/java/com/orbekk/stats/TestClient.java
blob: b7fb5950a93b47cfe47473ea46aa8c1d63a4cde0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.orbekk.stats;

import java.io.IOException;
import java.net.UnknownHostException;

import com.google.protobuf.RpcCallback;
import com.orbekk.protobuf.Rpc;
import com.orbekk.protobuf.RpcChannel;
import com.orbekk.stats.Experiments.Empty;
import com.orbekk.stats.Experiments.Experiment1;
import com.orbekk.stats.Experiments.SimpleTiming;

public class TestClient {
    public static void main(String[] args) {
        RpcChannel channel = null;
        try {
            RpcCallback<Empty> done = new RpcCallback<Empty>() {
                @Override public void run(Empty unused) {
                }
            };
            channel = RpcChannel.create("localhost", Common.PORT);
            Experiment1 exp1 = Experiment1Impl.newStub(channel);
            Rpc rpc = new Rpc();
            rpc.setTimeout(5000);
            SimpleTiming timing = SimpleTiming.newBuilder()
                    .setTiming(1337.0)
                    .setNumDevices(0)
                    .build();
            exp1.registerSample(rpc, timing, done);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (channel != null) {
                channel.close();
            }
        }
    }
}