- @Override
- public void onReceive(Object message) throws Exception {
- if(message instanceof FindPrimary ){
- FindPrimary msg = ((FindPrimary) message);
- getSender().tell(new PrimaryNotFound(msg.getShardName()), getSelf());
- }
+ public static Props props(final String type){
+ return Props.create(new Creator<ShardManager>(){
+
+ @Override
+ public ShardManager create() throws Exception {
+ return new ShardManager(type);
+ }
+ });
+ }
+
+ @Override
+ public void handleReceive(Object message) throws Exception {
+ if (message instanceof FindPrimary) {
+ FindPrimary msg = ((FindPrimary) message);
+ String shardName = msg.getShardName();
+ if(Shard.DEFAULT_NAME.equals(shardName)){
+ getSender().tell(new PrimaryFound(defaultShardPath.toString()), getSelf());
+ } else {
+ getSender().tell(new PrimaryNotFound(shardName), getSelf());
+ }
+ } else if(message instanceof UpdateSchemaContext){
+ // FIXME : Notify all local shards of a context change
+ getContext().system().actorSelection(defaultShardPath).forward(message, getContext());