Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to NodeFactory to obtain the address of a given Node.
Split LocalGroup into 2 implementations, one implementing NodeFactory<org.jgroups.Address> and the other implementing NodeFactory<org.infinispan.remoting.transport.Address>
- Loading branch information
Showing
11 changed files
with
264 additions
and
82 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 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
85 changes: 85 additions & 0 deletions
85
clustering/server/src/main/java/org/wildfly/clustering/server/group/AbstractLocalGroup.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,85 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2018, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.clustering.server.group; | ||
|
||
import org.wildfly.clustering.Registration; | ||
import org.wildfly.clustering.group.GroupListener; | ||
import org.wildfly.clustering.group.Membership; | ||
import org.wildfly.clustering.group.Node; | ||
|
||
/** | ||
* Abstract non-clustered group implementation. | ||
* Registered {@link GroupListener} are never invoked, as membership of a local group is fixed. | ||
* @author Paul Ferraro | ||
*/ | ||
public abstract class AbstractLocalGroup<A> implements Group<A>, Registration { | ||
private static final String NAME = "local"; | ||
|
||
private final Membership membership; | ||
|
||
public AbstractLocalGroup(String nodeName) { | ||
this.membership = new SingletonMembership(new LocalNode(nodeName)); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// We never registered anything | ||
} | ||
|
||
@Override | ||
public Registration register(GroupListener listener) { | ||
// Nothing to register | ||
return this; | ||
} | ||
|
||
@Deprecated | ||
@Override | ||
public void removeListener(org.wildfly.clustering.group.Group.Listener listener) { | ||
// We never registered anything | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public Node getLocalMember() { | ||
return this.membership.getCoordinator(); | ||
} | ||
|
||
@Override | ||
public Membership getMembership() { | ||
return this.membership; | ||
} | ||
|
||
@Override | ||
public boolean isSingleton() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Node createNode(A address) { | ||
return this.getLocalMember(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...g/server/src/main/java/org/wildfly/clustering/server/group/AbstractLocalGroupBuilder.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,61 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2018, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.clustering.server.group; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.jboss.as.clustering.controller.CapabilityServiceBuilder; | ||
import org.jboss.as.server.ServerEnvironment; | ||
import org.jboss.as.server.ServerEnvironmentService; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.jboss.msc.service.ServiceTarget; | ||
import org.wildfly.clustering.group.Group; | ||
import org.wildfly.clustering.service.InjectedValueDependency; | ||
import org.wildfly.clustering.service.MappedValueService; | ||
import org.wildfly.clustering.service.ValueDependency; | ||
|
||
/** | ||
* Builds a non-clustered {@link Group}. | ||
* @author Paul Ferraro | ||
*/ | ||
public abstract class AbstractLocalGroupBuilder implements CapabilityServiceBuilder<Group>, Function<ServerEnvironment, Group> { | ||
|
||
private final ServiceName name; | ||
private final ValueDependency<ServerEnvironment> environment = new InjectedValueDependency<>(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class); | ||
|
||
public AbstractLocalGroupBuilder(ServiceName name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public ServiceName getServiceName() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public ServiceBuilder<Group> build(ServiceTarget target) { | ||
return this.environment.register(target.addService(this.name, new MappedValueService<>(this, this.environment))).setInitialMode(ServiceController.Mode.ON_DEMAND); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
clustering/server/src/main/java/org/wildfly/clustering/server/group/LocalCacheGroup.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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2018, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.clustering.server.group; | ||
|
||
import org.infinispan.remoting.transport.Address; | ||
import org.infinispan.remoting.transport.LocalModeAddress; | ||
import org.wildfly.clustering.group.Node; | ||
|
||
/** | ||
* Non-clustered cache group. | ||
* @author Paul Ferraro | ||
*/ | ||
public class LocalCacheGroup extends AbstractLocalGroup<Address> { | ||
|
||
public LocalCacheGroup(String nodeName) { | ||
super(nodeName); | ||
} | ||
|
||
@Override | ||
public Address getAddress(Node node) { | ||
return LocalModeAddress.INSTANCE; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ring/server/src/main/java/org/wildfly/clustering/server/group/LocalCacheGroupBuilder.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,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2018, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.wildfly.clustering.server.group; | ||
|
||
import org.jboss.as.server.ServerEnvironment; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.wildfly.clustering.group.Group; | ||
|
||
/** | ||
* Builds a non-clustered cache {@link Group} service. | ||
* @author Paul Ferraro | ||
*/ | ||
public class LocalCacheGroupBuilder extends AbstractLocalGroupBuilder { | ||
|
||
public LocalCacheGroupBuilder(ServiceName name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
public Group apply(ServerEnvironment environment) { | ||
return new LocalCacheGroup(environment.getNodeName()); | ||
} | ||
} |
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
Oops, something went wrong.