-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create actor builder, add cluster join actor
- Loading branch information
1 parent
adc3c18
commit 4bb2285
Showing
11 changed files
with
368 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright 2016 InscopeMetrics, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.arpnetworking.akka; | ||
|
||
import akka.actor.Props; | ||
import com.arpnetworking.commons.builder.OvalBuilder; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* Builder for actors. | ||
* | ||
* @param <B> The type of the builder | ||
* @author Brandon Arp (brandon dot arp at inscopemetrics dot com) | ||
*/ | ||
public abstract class ActorBuilder<B extends ActorBuilder<B>> extends OvalBuilder<Props> { | ||
/** | ||
* Protected constructor. | ||
* | ||
* @param createProps method to create a {@link Props} from the {@link ActorBuilder} | ||
*/ | ||
protected ActorBuilder(final Function<B, Props> createProps) { | ||
super(createProps); | ||
} | ||
|
||
/** | ||
* Called by setters to always return appropriate subclass of | ||
* {@link ActorBuilder}, even from setters of base class. | ||
* | ||
* @return instance with correct {@link ActorBuilder} class type. | ||
*/ | ||
protected abstract B self(); | ||
} |
90 changes: 90 additions & 0 deletions
90
src/main/java/com/arpnetworking/akka/NonJoiningClusterJoiner.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,90 @@ | ||
/** | ||
* Copyright 2016 Inscope Metrics, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.arpnetworking.akka; | ||
|
||
import akka.actor.Props; | ||
import akka.actor.UntypedActor; | ||
import com.arpnetworking.steno.Logger; | ||
import com.arpnetworking.steno.LoggerFactory; | ||
|
||
/** | ||
* Actor that does not attempt to join a cluster. | ||
* | ||
* @author Brandon Arp (brandon dot arp at inscopemetrics dot com) | ||
*/ | ||
public final class NonJoiningClusterJoiner extends UntypedActor { | ||
/** | ||
* Static factory method for creating a {@link Props} to create a {@link NonJoiningClusterJoiner} actor. | ||
* | ||
* @return a new {@link Props} | ||
*/ | ||
public static Props props() { | ||
return Props.create(NonJoiningClusterJoiner.class); | ||
} | ||
|
||
/** | ||
* Static factory method for creating a {@link Props} to create a {@link NonJoiningClusterJoiner} actor from a | ||
* {@link Builder}. | ||
* | ||
* @param builder Builder to create the Props from | ||
* @return a new {@link Props} | ||
*/ | ||
private static Props props(final Builder builder) { | ||
return props(); | ||
} | ||
|
||
/** | ||
* Public constructor. | ||
*/ | ||
public NonJoiningClusterJoiner() { | ||
LOGGER.info() | ||
.setMessage("NonJoiningClusterJoiner starting up") | ||
.log(); | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void onReceive(final Object message) throws Exception { | ||
unhandled(message); | ||
} | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(NonJoiningClusterJoiner.class); | ||
|
||
/** | ||
* Implementation of the {@link com.arpnetworking.commons.builder.Builder} pattern for a {@link NonJoiningClusterJoiner}. | ||
* | ||
* @author Brandon Arp (brandon dot arp at inscopemetrics dot com) | ||
*/ | ||
public static class Builder extends ActorBuilder<Builder> { | ||
/** | ||
* Public constructor. | ||
*/ | ||
public Builder() { | ||
super(NonJoiningClusterJoiner::props); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Builder self() { | ||
return this; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.