-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-1.0.0' into stable
- Loading branch information
Showing
9 changed files
with
164 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
rm -rf artifacts/* | ||
mvn package || exit 1 | ||
cd artifacts | ||
unzip cbjgroups-1.0.0.jar | ||
echo "Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: CBJgroups Java Services | ||
Bundle-SymbolicName: org.pixl8.cbjgroups | ||
Bundle-Version: 1.0.0 | ||
" > META-INF/MANIFEST.MF | ||
rm cbjgroups-1.0.0.jar | ||
zip -rq cbjgroups-1.0.0.jar * | ||
|
||
cp cbjgroups-1.0.0.jar ../../lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
java-src/src/main/java/org/pixl8/cbjgroups/CbJGroupsClusterWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.pixl8.cbjgroups; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.util.Map; | ||
import java.io.FileNotFoundException; | ||
|
||
import org.jgroups.*; | ||
import lucee.runtime.Component; | ||
import lucee.runtime.exp.PageException; | ||
import lucee.loader.engine.CFMLEngineFactory; | ||
import lucee.runtime.type.Struct; | ||
import lucee.runtime.type.Array; | ||
|
||
|
||
public class CbJGroupsClusterWrapper { | ||
|
||
private JChannel _channel; | ||
|
||
// CONSTRUCTOR | ||
public CbJGroupsClusterWrapper( String configFilePath, Boolean discardOwnMessages, Component listenerCfc, Component loggerCfc, String contextRoot ) throws PageException, FileNotFoundException, Exception { | ||
if ( configFilePath.length() > 0 ) { | ||
_channel = new JChannel( new FileInputStream( new File( configFilePath ) ) ); | ||
} else { | ||
_channel = new JChannel(); | ||
} | ||
|
||
_channel.setDiscardOwnMessages( discardOwnMessages ); | ||
_channel.setReceiver( new CbJGroupsMessageReceiver( listenerCfc, loggerCfc, contextRoot ) ); | ||
} | ||
|
||
// PUBLIC API | ||
public Boolean connect( String clusterName ) throws Exception { | ||
if ( !isConnected() ) { | ||
_channel.connect( clusterName ); | ||
return isConnected(); | ||
} | ||
return true; | ||
} | ||
|
||
public void close() { | ||
_channel.disconnect(); | ||
_channel.close(); | ||
} | ||
|
||
public Boolean isConnected() { | ||
return _channel.isConnected(); | ||
} | ||
|
||
public void sendMessage( String msg ) throws Exception { | ||
_channel.send( new Message( null, msg.getBytes() ) ); | ||
} | ||
|
||
public Struct getStats() throws PageException { | ||
Struct stats = CFMLEngineFactory.getInstance().getCreationUtil().createStruct(); | ||
Array memberAddresses = CFMLEngineFactory.getInstance().getCreationUtil().createArray(); | ||
Address[] members = _channel.getView().getMembersRaw(); | ||
Map<String, Object> dumpStats = (Map<String, Object>)_channel.dumpStats().get( "channel" ); | ||
|
||
for (String key : dumpStats.keySet()) { | ||
stats.put( key, dumpStats.get( key ) ); | ||
} | ||
for( int i=0; i<members.length; i++ ) { | ||
memberAddresses.append( members[i].toString() ); | ||
} | ||
|
||
stats.put( "members", memberAddresses ); | ||
stats.put( "self", _channel.getAddress().toString() ); | ||
stats.put( "is_coordinator", members.length <= 1 || members[0].equals( _channel.getAddress() ) ); | ||
|
||
if ( _channel.isConnected() ) { | ||
stats.put( "connection", "CONNECTED" ); | ||
} else if ( _channel.isConnecting() ) { | ||
stats.put( "connection", "CONNECTING" ); | ||
} else if ( _channel.isOpen() ) { | ||
stats.put( "connection", "DISCONNECTED" ); | ||
} else { | ||
stats.put( "connection", "CLOSED" ); | ||
} | ||
|
||
return stats; | ||
} | ||
|
||
public Boolean isCoordinator() { | ||
Address[] members = _channel.getView().getMembersRaw(); | ||
|
||
return members.length <= 1 || members[0].equals( _channel.getAddress() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters