Examples of ConfigPath


Examples of io.fathom.auto.config.ConfigPath

    public List<Endpoint> lookup(String serviceKey) {
        List<Endpoint> endpoints = Lists.newArrayList();

        try {
            ConfigPath parent = endpointsRoot.child(serviceKey);
            for (ConfigEntry child : parent.listChildren()) {
                String name = child.getName();
                String data = parent.readChild(name);

                EndpointData record = JsonCodec.gson.fromJson(data, EndpointData.class);

                Endpoint endpoint = new Endpoint(record);
                endpoints.add(endpoint);
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        this.path = path;
    }

    @Override
    protected void createFile(String key, String contents) throws IOException {
        ConfigPath childPath = path.child(key);
        try {
            childPath.write(contents);
        } catch (IOException e) {
            throw new IOException("Error writing cloud file", e);
        }
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        }
    }

    @Override
    protected void deleteFile(String key) throws IOException {
        ConfigPath childPath = path.child(key);
        try {
            childPath.delete();
        } catch (IOException e) {
            throw new IOException("Error deleting cloud file", e);
        }
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        }
    }

    public void register(String serviceKey, InetSocketAddress addr) {
        try {
            ConfigPath parent = endpointsRoot.child(serviceKey);

            EndpointData record = new EndpointData();
            record.address = InetSocketAddresses.toString(addr);

            String machineKey = MachineInfo.INSTANCE.getMachineKey();

            ConfigPath node = parent.child(machineKey);
            String json = JsonCodec.gson.toJson(record);
            node.write(json);
        } catch (IOException e) {
            // TODO: Retry??
            throw new IllegalArgumentException("Error writing endpoint entry", e);
        }
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        this.base = base;
        this.lock = lock;
    }

    public void writeRegistration(int serverId, T registration) throws IOException {
        ConfigPath node = getServerPath(serverId);

        String json = JsonCodec.gson.toJson(registration);
        node.write(json);
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        String json = JsonCodec.gson.toJson(registration);
        node.write(json);
    }

    public List<Integer> getServerIds() throws IOException {
        ConfigPath servers = base.child("servers");
        List<Integer> serverIds = Lists.newArrayList();

        Iterable<ConfigEntry> children = servers.listChildren();
        if (children == null) {
            // Not found
            return null;
        }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        return serverIds;
    }

    private ConfigPath getServerPath(int serverId) {
        ConfigPath servers = base.child("servers");
        ConfigPath me = servers.child("" + serverId);
        return me;
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        ConfigPath me = servers.child("" + serverId);
        return me;
    }

    private T readServerRegistration(int serverId) throws IOException {
        ConfigPath node = getServerPath(serverId);

        String json = node.read();
        if (json == null) {
            return null;
        }

        T registration = deserialize(json);
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

        this.secretKeys = configStore.getSecretKeys();
    }

    @Override
    public ConfigSync getConfigSync(File mirrorPath) {
        ConfigPath serversPath = configStore.getConfigRoot().child("data");
        return new ServerConfig(serversPath, mirrorPath);
    }
View Full Code Here

Examples of io.fathom.auto.config.ConfigPath

    public void run() throws IOException, InterruptedException {
        Thread zkThread = new Thread(new Runnable() {
            @Override
            public void run() {
                ConfigPath configRoot = configStore.getConfigRoot();
                ConfigPath zkRoot = configRoot.child("zookeeper");

                ZookeeperInstance zk = new ZookeeperInstance(zkRoot);
                try {
                    zk.run();
                } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.