Java Code Examples for org.jvirtanen.config.Configs#getNetworkInterface()

The following examples show how to use org.jvirtanen.config.Configs#getNetworkInterface() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StockTicker.java    From parity with Apache License 2.0 6 votes vote down vote up
private static void listen(Config config, MessageListener listener) throws IOException {
    if (config.hasPath("market-data.multicast-interface")) {
        NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
        InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
        int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
        InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
        int              requestPort        = Configs.getPort(config, "market-data.request-port");

        MoldUDP64.receive(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
                new InetSocketAddress(requestAddress, requestPort), listener);
    } else {
        InetAddress address  = Configs.getInetAddress(config, "market-data.address");
        int         port     = Configs.getPort(config, "market-data.port");
        String      username = config.getString("market-data.username");
        String      password = config.getString("market-data.password");

        SoupBinTCP.receive(new InetSocketAddress(address, port), username, password, listener);
    }
}
 
Example 2
Source File: TradeReporter.java    From parity with Apache License 2.0 6 votes vote down vote up
private static void main(Config config, boolean tsv) throws IOException {
    Instruments instruments = Instruments.fromConfig(config, "instruments");

    MessageListener listener = new PMRParser(new TradeProcessor(tsv ?
                new TSVFormat(instruments) : new DisplayFormat(instruments)));

    if (config.hasPath("trade-report.multicast-interface")) {
        NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "trade-report.multicast-interface");
        InetAddress      multicastGroup     = Configs.getInetAddress(config, "trade-report.multicast-group");
        int              multicastPort      = Configs.getPort(config, "trade-report.multicast-port");
        InetAddress      requestAddress     = Configs.getInetAddress(config, "trade-report.request-address");
        int              requestPort        = Configs.getPort(config, "trade-report.request-port");

        MoldUDP64.receive(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
                new InetSocketAddress(requestAddress, requestPort), listener);
    } else {
        InetAddress address  = Configs.getInetAddress(config, "trade-report.address");
        int         port     = Configs.getPort(config, "trade-report.port");
        String      username = config.getString("trade-report.username");
        String      password = config.getString("trade-report.password");

        SoupBinTCP.receive(new InetSocketAddress(address, port), username, password, listener);
    }
}
 
Example 3
Source File: Simulator.java    From parity-extras with Apache License 2.0 5 votes vote down vote up
private static MarketData marketData(Config config) throws IOException {
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
    int              requestPort        = Configs.getPort(config, "market-data.request-port");

    String instrument = config.getString("instrument");

    return MarketData.open(multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort),
            ASCII.packLong(instrument));
}
 
Example 4
Source File: Gateway.java    From nassau with Apache License 2.0 5 votes vote down vote up
private static UpstreamFactory upstream(Config config) {
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "upstream.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "upstream.multicast-group");
    int              multicastPort      = Configs.getPort(config, "upstream.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "upstream.request-address");
    int              requestPort        = Configs.getPort(config, "upstream.request-port");

    return new UpstreamFactory(multicastInterface, new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}
 
Example 5
Source File: TradingSystem.java    From parity with Apache License 2.0 5 votes vote down vote up
private static MarketData marketData(Config config) throws IOException {
    String           session            = config.getString("market-data.session");
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-data.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-data.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-data.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-data.request-address");
    int              requestPort        = Configs.getPort(config, "market-data.request-port");

    return MarketData.open(session, multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}
 
Example 6
Source File: TradingSystem.java    From parity with Apache License 2.0 5 votes vote down vote up
private static MarketReporting marketReporting(Config config) throws IOException {
    String           session            = config.getString("market-report.session");
    NetworkInterface multicastInterface = Configs.getNetworkInterface(config, "market-report.multicast-interface");
    InetAddress      multicastGroup     = Configs.getInetAddress(config, "market-report.multicast-group");
    int              multicastPort      = Configs.getPort(config, "market-report.multicast-port");
    InetAddress      requestAddress     = Configs.getInetAddress(config, "market-report.request-address");
    int              requestPort        = Configs.getPort(config, "market-report.request-port");

    return MarketReporting.open(session, multicastInterface,
            new InetSocketAddress(multicastGroup, multicastPort),
            new InetSocketAddress(requestAddress, requestPort));
}