use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class TCPGOSSIP method removeInitialHost.
@ManagedOperation
public boolean removeInitialHost(String hostname, int port) {
InetSocketAddress isa = new InetSocketAddress(hostname, port);
stubManager.unregisterStub(new IpAddress(isa.getAddress(), isa.getPort()));
return initial_hosts.remove(isa);
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class Discovery method addToCache.
@ManagedOperation(description = "Reads logical-physical address mappings and logical name mappings from a " + "file (or URL) and adds them to the local caches")
public void addToCache(String filename) throws Exception {
InputStream in = ConfiguratorFactory.getConfigStream(filename);
List<PingData> list = read(in);
if (list != null)
for (PingData data : list) addDiscoveryResponseToCaches(data.getAddress(), data.getLogicalName(), data.getPhysicalAddr());
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class INJECT_VIEW method injectView.
@ManagedOperation(description = "Inject a view (example of view string format: A=A/B/C;B=B/C;C=C)")
public synchronized void injectView(String newView) {
try {
log.info("[INJECT_VIEW] Received request to inject view %s\n", newView);
String[] perNode = newView.split(NODE_VIEWS_SEPARATOR);
String thisNodeAddress = getProtocolStack().getChannel().getAddressAsString();
for (String nodeView : perNode) {
if (nodeView.startsWith(thisNodeAddress)) {
log.info("[INJECT_VIEW] [channel: %s] Injecting a new view: %s\n", thisNodeAddress, nodeView);
long viewId = getProtocolStack().getChannel().getView().getViewId().getId() + 1;
List<Address> nodes = new ArrayList<>();
for (String nodeName : nodeView.split(VIEW_SEPARATOR)[1].split(NAMES_SEPARATOR)) {
for (Map.Entry<Address, String> entry : NameCache.getContents().entrySet()) {
if (nodeName.equals(entry.getValue())) {
log.debug("[INJECT_VIEW] [channel: %s] Found name: <%s> for address: <%s>\n", entry.getValue(), entry.getKey().toString());
nodes.add(entry.getKey());
break;
}
}
}
View view = new View(nodes.get(0), viewId, nodes);
GMS gms = getProtocolStack().findProtocol(GMS.class);
gms.installView(view);
log.info("[INJECT_VIEW] [channel: %s] Injection finished of view: %s\n", thisNodeAddress, nodeView);
}
}
} catch (Exception e) {
log.warn(e.getMessage(), e);
}
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class ReplCache method stop.
@ManagedOperation
public void stop() {
if (l1_cache != null)
l1_cache.stop();
if (migrate_data) {
List<Address> members_without_me = new ArrayList<>(view.getMembers());
members_without_me.remove(local_addr);
HashFunction<K> tmp_hash_function = hash_function_factory.create();
tmp_hash_function.installNodes(members_without_me);
for (Map.Entry<K, Cache.Value<Value<V>>> entry : l2_cache.entrySet()) {
K key = entry.getKey();
Cache.Value<Value<V>> val = entry.getValue();
if (val == null)
continue;
Value<V> tmp = val.getValue();
if (tmp == null)
continue;
short repl_count = tmp.getReplicationCount();
if (// we only handle keys which are not replicated and which are stored by us
repl_count != 1)
continue;
List<Address> nodes = tmp_hash_function.hash(key, repl_count);
if (nodes == null || nodes.isEmpty())
continue;
if (!nodes.contains(local_addr)) {
// should only have 1 element anyway
Address dest = nodes.get(0);
move(dest, key, tmp.getVal(), repl_count, val.getTimeout(), true);
_remove(key);
}
}
}
l2_cache.removeChangeListener(this);
l2_cache.stop();
disp.stop();
ch.close();
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class ReplCache method start.
@ManagedOperation
public void start() throws Exception {
if (hash_function_factory != null) {
hash_function = hash_function_factory.create();
}
if (hash_function == null)
hash_function = new ConsistentHashFunction<>();
ch = new JChannel(props);
disp = new RpcDispatcher(ch, this).setMethodLookup(methods::get).setMembershipListener(this);
Marshaller marshaller = new CustomMarshaller();
disp.setMarshaller(marshaller);
ch.connect(cluster_name);
local_addr = ch.getAddress();
view = ch.getView();
timer = ch.getProtocolStack().getTransport().getTimer();
l2_cache.addChangeListener(this);
}
Aggregations