/** * @param value * {@link ReplicaSystem} implementation class name * @return A {@link ReplicaSystem} object from the given name */ public ReplicaSystem get(ServerContext context, String value) { final Entry<String,String> entry = parseReplicaSystemConfiguration(value); try { Class<?> clz = Class.forName(entry.getKey()); if (ReplicaSystem.class.isAssignableFrom(clz)) { Object o = clz.newInstance(); ReplicaSystem rs = (ReplicaSystem) o; rs.configure(context, entry.getValue()); return rs; } throw new IllegalArgumentException( "Class is not assignable to ReplicaSystem: " + entry.getKey()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { log.error("Error creating ReplicaSystem object", e); throw new IllegalArgumentException(e); } }
/** * Extract replication peers from system configuration * * @return Configured replication peers */ public Map<String,String> getPeers() { Map<String,String> peers = new HashMap<>(); // Get the defined peers and what ReplicaSystem impl they're using for (Entry<String,String> property : context.getConfiguration() .getAllPropertiesWithPrefix(Property.REPLICATION_PEERS).entrySet()) { String key = property.getKey(); // Filter out cruft that we don't want if (!key.startsWith(Property.REPLICATION_PEER_USER.getKey()) && !key.startsWith(Property.REPLICATION_PEER_PASSWORD.getKey()) && !key.startsWith(Property.REPLICATION_PEER_KEYTAB.getKey())) { String peerName = property.getKey().substring(Property.REPLICATION_PEERS.getKey().length()); Entry<String,String> entry; try { entry = factory.parseReplicaSystemConfiguration(property.getValue()); } catch (Exception e) { log.warn("Could not instantiate ReplicaSystem for {} with configuration {}", property.getKey(), property.getValue(), e); continue; } peers.put(peerName, entry.getKey()); } } return peers; }
/** * @param value * {@link ReplicaSystem} implementation class name * @return A {@link ReplicaSystem} object from the given name */ public ReplicaSystem get(String value) { final Entry<String,String> entry = parseReplicaSystemConfiguration(value); try { Class<?> clz = Class.forName(entry.getKey()); if (ReplicaSystem.class.isAssignableFrom(clz)) { Object o = clz.newInstance(); ReplicaSystem rs = (ReplicaSystem) o; rs.configure(entry.getValue()); return rs; } throw new IllegalArgumentException( "Class is not assignable to ReplicaSystem: " + entry.getKey()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { log.error("Error creating ReplicaSystem object", e); throw new IllegalArgumentException(e); } }
/** * Extract replication peers from system configuration * * @return Configured replication peers */ public Map<String,String> getPeers() { Map<String,String> peers = new HashMap<>(); // Get the defined peers and what ReplicaSystem impl they're using for (Entry<String,String> property : context.getConfiguration() .getAllPropertiesWithPrefix(Property.REPLICATION_PEERS).entrySet()) { String key = property.getKey(); // Filter out cruft that we don't want if (!key.startsWith(Property.REPLICATION_PEER_USER.getKey()) && !key.startsWith(Property.REPLICATION_PEER_PASSWORD.getKey()) && !key.startsWith(Property.REPLICATION_PEER_KEYTAB.getKey())) { String peerName = property.getKey().substring(Property.REPLICATION_PEERS.getKey().length()); Entry<String,String> entry; try { entry = factory.parseReplicaSystemConfiguration(property.getValue()); } catch (Exception e) { log.warn("Could not instantiate ReplicaSystem for {} with configuration {}", property.getKey(), property.getValue(), e); continue; } peers.put(peerName, entry.getKey()); } } return peers; }