Skip to content

Commit

Permalink
updated for JASocket 3.1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
laforge49 committed Feb 1, 2013
1 parent 9565ec4 commit 80153e6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>org.agilewiki.jasocket</groupId>
<artifactId>jasocket</artifactId>
<version>3.0.0.0</version>
<version>3.1.0.0</version>
</dependency>
<dependency>
<groupId>org.agilewiki.jfile</groupId>
Expand Down
2 changes: 1 addition & 1 deletion release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>org.agilewiki.jasocket</groupId>
<artifactId>jasocket</artifactId>
<version>3.0.0.0</version>
<version>3.1.0.0</version>
</dependency>
<dependency>
<groupId>org.agilewiki.jfile</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/agilewiki/jaconfig/ClusterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void processResponse(AgentChannel response) throws Exception {
if (response != null) {
ServerEvalAgent serverEvalAgent = (ServerEvalAgent) node().factory().newActor(
ServerEvalAgentFactory.fac.actorType, getMailbox());
serverEvalAgent.configure("*clusterManager*", "shutdown");
serverEvalAgent.configure("*clusterManager*", null, "shutdown");
(new ShipAgent(serverEvalAgent)).send(ClusterManager.this, response, new RP<Jid>() {
@Override
public void processResponse(Jid response) throws Exception {
Expand Down
34 changes: 30 additions & 4 deletions src/main/java/org/agilewiki/jaconfig/db/impl/ConfigServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ protected void startServer(final PrintJid out, final RP rp) throws Exception {
map = (StringBMapJid<TimeValueJid>) rootJid.getValue();
registerServerCommand(new ServerCommand("values", "list all names and their assigned values") {
@Override
public void eval(String operatorName, String args, PrintJid out, long requestId, RP<PrintJid> rp) throws Exception {
public void eval(String operatorName,
String id,
AgentChannel agentChannel,
String args,
PrintJid out,
long requestId,
RP<PrintJid> rp) throws Exception {
int s = map.size();
int i = 0;
while (i < s) {
Expand All @@ -138,15 +144,24 @@ public void eval(String operatorName, String args, PrintJid out, long requestId,
TimeValueJid tv = me.getValue();
String value = tv.getValue();
if (value.length() > 0)
out.println(name + " = " + value);
if (name.endsWith(".password"))
out.println(name + " = **********");
else
out.println(name + " = " + value);
i += 1;
}
rp.processResponse(out);
}
});
registerServerCommand(new ServerCommand("assign", "set a name to a value") {
@Override
public void eval(String operatorName, String args, PrintJid out, long requestId, RP<PrintJid> rp) throws Exception {
public void eval(String operatorName,
String id,
AgentChannel agentChannel,
String args,
PrintJid out,
long requestId,
RP<PrintJid> rp) throws Exception {
if (args.length() == 0) {
out.println("missing name");
} else {
Expand Down Expand Up @@ -202,6 +217,8 @@ public boolean assign(String name, long timestamp, String value) throws Exceptio

public String get(String name) throws Exception {
TimeValueJid tv = map.kGet(name);
if (tv == null)
return "";
return tv.getValue();
}

Expand Down Expand Up @@ -259,6 +276,15 @@ public static void main(String[] args) throws Exception {

@Override
public boolean authenticate(String username, String password, ServerSession session) {
return !username.contains(" ");
try {
if (!username.contains(" "))
return false;
String stored = get(username + ".password");
if (stored.length() == 0)
return username.equals("admin") && password.equals("admin");
return stored.equals(password);
} catch (Exception ex) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public void processResponse(AgentChannel response) throws Exception {
StartupAgentFactory.fac.actorType, getMailbox());
startupAgent.configure(
"*quorumServer*",
null,
startupEntry.className + " " + startupEntry.serverName + " " + startupEntry.serverArgs);
(new ShipAgent(startupAgent)).send(QuorumServer.this, response, new RP<Jid>() {
@Override
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/agilewiki/jaconfig/rank/RankerServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.agilewiki.jaconfig.rank;

import org.agilewiki.jactor.RP;
import org.agilewiki.jasocket.agentChannel.AgentChannel;
import org.agilewiki.jasocket.jid.PrintJid;
import org.agilewiki.jasocket.server.Server;
import org.agilewiki.jasocket.server.ServerCommand;
Expand All @@ -42,7 +43,13 @@ protected String serverName() {
protected void startServer(PrintJid out, RP rp) throws Exception {
registerServerCommand(new ServerCommand("nodes", "list nodes, least busy first") {
@Override
public void eval(String operatorName, String args, final PrintJid out, long requestId, final RP<PrintJid> rp) throws Exception {
public void eval(String operatorName,
String id,
AgentChannel agentChannel,
String args,
final PrintJid out,
long requestId,
final RP<PrintJid> rp) throws Exception {
ranking(args, new RP<List<String>>() {
@Override
public void processResponse(List<String> response) throws Exception {
Expand Down

0 comments on commit 80153e6

Please sign in to comment.