Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Added dump_jdbc.sh to dump all elements of the table created by JDB…
…C_PING

- JDBC_PING now subclasses FILE_PING instead of Discovery instead (https://issues.jboss.org/browse/JGRP-2064)
  • Loading branch information
belaban committed Sep 21, 2016
1 parent 8f124d4 commit 45a20a2
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 163 deletions.
2 changes: 2 additions & 0 deletions bin/dump_jdbc.sh
@@ -0,0 +1,2 @@
#!/bin/bash
jgroups.sh org.jgroups.protocols.JDBC_PING $*
39 changes: 20 additions & 19 deletions src/org/jgroups/protocols/FILE_PING.java
Expand Up @@ -33,26 +33,29 @@ public class FILE_PING extends Discovery {


@Property(description="The absolute path of the shared file")
protected String location=File.separator + "tmp" + File.separator + "jgroups";
protected String location=File.separator + "tmp" + File.separator + "jgroups";

@Property(description="If true, on a view change, the new coordinator removes files from old coordinators")
protected boolean remove_old_coords_on_view_change=false;
protected boolean remove_old_coords_on_view_change;

@Property(description="If true, on a view change, the new coordinator removes all files except its own")
protected boolean remove_all_files_on_view_change=false;
@Property(description="If true, on a view change, the new coordinator removes all data except its own")
protected boolean remove_all_data_on_view_change;

@Property(description="The max number of times my own information should be written to the DB after a view change")
protected int info_writer_max_writes_after_view=2;
@Property(description="The max number of times my own information should be written to the storage after a view change")
protected int info_writer_max_writes_after_view=2;

@Property(description="Interval (in ms) at which the info writer should kick in")
protected long info_writer_sleep_time=10000;
protected long info_writer_sleep_time=10000;

@Property(description = "If set, a shutdown hook is registered with the JVM to remove the local address "
+ "from the store. Default is true", writable = false)
protected boolean register_shutdown_hook = true;

@ManagedAttribute(description="Number of writes to the file system or cloud store")
protected int writes;
protected int writes;

@ManagedAttribute(description="Number of reads from the file system or cloud store")
protected int reads;
protected int reads;


/* --------------------------------------------- Fields ------------------------------------------------------ */
Expand All @@ -71,19 +74,20 @@ public class FILE_PING extends Discovery {
public void init() throws Exception {
super.init();
createRootDir();
try {
if(register_shutdown_hook) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
remove(cluster_name, local_addr);
}
});
}
// This can be thrown if the JVM is already in the process of shutting down
catch (IllegalStateException e) {
log.debug("Unable to add shutdown hook for " + this.getClass().getCanonicalName() + ". File " + cluster_name + "/" + addressToFilename(local_addr) + " may not be deleted.");
}
}

public void stop() {
super.stop();
stopInfoWriter();
remove(cluster_name, local_addr);
}

public void resetStats() {
super.resetStats();
Expand All @@ -99,9 +103,6 @@ public Object down(Event evt) {
View new_view=evt.getArg();
handleView(new_view, old_view, previous_coord != is_coord);
return retval;
case Event.DISCONNECT:
remove(cluster_name, local_addr);
break;
}
return super.down(evt);
}
Expand Down Expand Up @@ -169,7 +170,7 @@ protected void createRootDir() {
protected void handleView(View new_view, View old_view, boolean coord_changed) {
if(is_coord) {
if(coord_changed) {
if(remove_all_files_on_view_change)
if(remove_all_data_on_view_change)
removeAll(cluster_name);
else if(remove_old_coords_on_view_change) {
Address old_coord=old_view != null? old_view.getCreator() : null;
Expand All @@ -179,7 +180,7 @@ else if(remove_old_coords_on_view_change) {
}
if(coord_changed || View.diff(old_view, new_view)[1].length > 0) {
writeAll();
if(remove_all_files_on_view_change || remove_old_coords_on_view_change)
if(remove_all_data_on_view_change || remove_old_coords_on_view_change)
startInfoWriter();
}
}
Expand Down

0 comments on commit 45a20a2

Please sign in to comment.