public NastyStorage(Gondola gondola, String hostId) throws Exception { String storageClassName = gondola.getConfig().get(gondola.getConfig().get("storage_nasty.impl") + ".class"); storage = (Storage) Class.forName(storageClassName).getConstructor(Gondola.class, String.class) .newInstance(gondola, hostId); tracing = gondola.getConfig().getBoolean("storage_nasty.tracing"); }
@Override public String getAddress() { InetSocketAddress addr = gondola.getConfig().getAddressForHost(hostId); return String.format("%s:%d", addr.getHostString(), addr.getPort()); /* try { return InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { logger.error(e.getMessage(), e); return "Unknown"; } */ }
@Override public String getAddress() { InetSocketAddress addr = gondola.getConfig().getAddressForHost(hostId); return String.format("%s:%d", addr.getHostString(), addr.getPort()); /* try { return InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { logger.error(e.getMessage(), e); return "Unknown"; } */ }
private String getAffinityColoShard() { String siteId = getSiteId(); Config config = gondola.getConfig(); return config.getHostIds().stream() .map(config::getSiteIdForHost) .filter(s -> s.equals(siteId)) .findAny().orElseThrow(() -> new IllegalStateException("Cannot find any shard in siteId=" + siteId)); }
public NastyStorage(Gondola gondola, String hostId) throws GondolaException { String storageClassName = gondola.getConfig().get(gondola.getConfig().get("storage.nasty.impl") + ".class"); try { storage = (Storage) Class.forName(storageClassName).getConstructor(Gondola.class, String.class) .newInstance(gondola, hostId); } catch (Exception e) { throw new GondolaException(e); } tracing = gondola.getConfig().getBoolean("storage.nasty.tracing"); }
private Map getConfigInfo(Gondola gondola) { Map<Object, Object> map = new LinkedHashMap<>(); Config config = gondola.getConfig(); map.put("file", config.getFile()); map.put("members", config.getMembers()); map.put("shards", config.getShardIds().stream() .map(config::getAttributesForShard) .collect(Collectors.toList())); map.put("hosts", config.getHostIds().stream() .map(config::getAttributesForHost) .collect(Collectors.toList())); return map; }
/** * Instantiates a new Change log processor. * * @param gondola the gondola * @param services the routing services */ public ChangeLogProcessor(Gondola gondola, Map<String, RoutingService> services) { this.gondola = gondola; this.services = services; gondola.getConfig().getShardIds(gondola.getHostId()).forEach(this::createThread); }
public SocketChannel(Gondola gondola, int memberId, int toMemberId) { this.gondola = gondola; this.memberId = memberId; this.peerId = toMemberId; gondola.getConfig().registerForUpdates(this); logger.info("[{}-{}] Creating connection to {}", gondola.getHostId(), memberId, toMemberId); inetSocketAddress = gondola.getConfig().getAddressForMember(peerId); reconnect(); }
public InetSocketAddress getAddress() { return gondola.getConfig().getAddressForMember(getMemberId()); } }
/** * Instantiates a new Lock manager. * * @param gondola The Gondola instance. */ public LockManager(Gondola gondola) { gondola.getConfig().registerForUpdates(config1 -> tracing = config1.getBoolean("tracing.router")); this.gondola = gondola; }
public SocketNetwork(Gondola gondola, String hostId) throws SocketException { this.gondola = gondola; this.hostId = hostId; gondola.getConfig().registerForUpdates(this); InetSocketAddress address = gondola.getConfig().getAddressForHost(hostId); if (!isLocalAddress(address.getAddress())) { throw new IllegalStateException(address.getHostName() + " is not a local address"); } // Check whether another process is already using this address if (isActive(getAddress())) { throw new IllegalStateException(String.format("Another process is actively listening to %s", getAddress())); } }
public ShardManagerServer getShardManagerServer(RoutingFilter filter) { Gondola gondola = filter.getGondola(); Utils.RegistryConfig conf = Utils.getRegistryConfig(gondola.getConfig()); ShardManager shardManager = new ShardManager(gondola, filter, gondola.getConfig(), getShardManagerClient(gondola.getConfig(), gondola.getHostId())); switch (conf.type) { case NONE: return null; case ZOOKEEPER: return new ZookeeperShardManagerServer(conf.attributes.get("serviceName"), conf.attributes.get("connectString"), gondola, shardManager); } throw new IllegalArgumentException("Unknown config"); }
public String getSiteId() { return gondola.getConfig().getSiteIdForHost(gondola.getHostId()); }
private void loadConfig() { gondola.getConfig().registerForUpdates(config -> tracing = config.getBoolean("tracing.router")); }
public InetSocketAddress getAddress() { return gondola.getConfig().getAddressForMember(getMemberId()); }
CommitQueue(Gondola gondola, CoreMember cmember) throws GondolaException { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null; //savedIndex; this.matchIndices = null; //matchIndices; gondola.getConfig().registerForUpdates(configListener); stats = gondola.getStats(); }
CommitQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null;//savedIndex; this.matchIndices = null;//matchIndices; gondola.getConfig().registerForUpdates(this); stats = gondola.getStats(); }
public ZookeeperShardManagerServer(String serviceName, String connectString, Gondola gondola, ShardManager shardmanager) { this.serviceName = serviceName; this.gondola = gondola; this.delegate = shardmanager; config = gondola.getConfig(); config.registerForUpdates(config -> tracing = config.getBoolean("tracing.router")); client = ZookeeperUtils.getCuratorFrameworkInstance(connectString); Watcher watcher = new Watcher(); watcher.start(); threads.add(watcher); initNode(gondola.getHostId()); ready = true; }
SaveQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; gondola.getConfig().registerForUpdates(this); storage = gondola.getStorage(); stats = gondola.getStats(); numWorkers = gondola.getConfig().getInt("storage.save_queue_workers"); String address = storage.getAddress(cmember.memberId); if (address != null && gondola.getNetwork().isActive(address)) { throw new IllegalStateException(String.format("[%s-%s] Process %s at address %s is currently using storage", gondola.getHostId(), cmember.memberId, gondola.getProcessId(), address)); } storage.setAddress(cmember.memberId, gondola.getNetwork().getAddress()); storage.setPid(cmember.memberId, gondola.getProcessId()); initSavedIndex(); }
public AdminResource() { Gondola gondola = GondolaApplication.getRoutingFilter().getGondola(); config = gondola.getConfig(); client = AdminClient.getInstance(config, "adminResource"); ShardManagerServer shardManagerServer = GondolaApplication.getShardManagerServer(); if (shardManagerServer != null) { shardManagerClient = GondolaApplication.getShardManagerServer().getShardManager().getShardManagerClient(); } }