import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.opendaylight.controller.cluster.datastore.messages.AddShardReplica;
-import org.opendaylight.controller.cluster.datastore.messages.RemoveShardReplica;
-import akka.pattern.Patterns;
-import akka.util.Timeout;
-import java.util.concurrent.TimeUnit;
-import scala.concurrent.Await;
public class ShardManagerInfo extends AbstractMXBean implements ShardManagerInfoMBean {
public void setShardManager(ShardManager shardManager){
this.shardManager = shardManager;
}
-
- @Override
- public void setAddShardReplica (String shardName) {
- LOG.info ("addShardReplica initiated for shard {}", shardName);
-
- // TODO addTimeout to be made configurable
- Timeout addTimeOut = new Timeout(1, TimeUnit.MINUTES);
- try {
- Await.result(Patterns.ask(shardManager.getSelf(),
- new AddShardReplica(shardName), addTimeOut),
- addTimeOut.duration());
- } catch (Exception ex) {
- LOG.debug ("Obtained an exception during addShardReplica", ex);
- throw (new RuntimeException(ex.getMessage()));
- }
- return;
- }
-
- @Override
- public void setRemoveShardReplica (String shardName) {
- LOG.info ("removeShardReplica initiated for shard {}", shardName);
-
- // TODO remTimeOut to be made configurable
- Timeout remTimeOut = new Timeout(30, TimeUnit.SECONDS);
- try {
- Await.result(Patterns.ask(shardManager.getSelf(),
- new RemoveShardReplica(shardName), remTimeOut),
- remTimeOut.duration());
- } catch (Exception ex) {
- LOG.debug ("Obtained an exception during removeShardReplica", ex);
- throw (new RuntimeException(ex.getMessage()));
- }
- return;
- }
}
* the term provided when switching to a new Leader should always be higher than the previous term.
*/
void switchShardState(String shardName, String newBehavior, long term);
-
- /**
- * Add a new Shard replica for an existing Shard in this controller node
- *
- * @param shardName the shard that is to be created and replicated in this controller instance
- */
- void setAddShardReplica (String shardName);
-
- /**
- * Remove a Shard replica available in this controller node
- *
- * @param shardName the shard that is to be removed from this controller instance
- */
- void setRemoveShardReplica (String shardName);
-
}