Package org.radargun.stages.helpers

Source Code of org.radargun.stages.helpers.RoleHelper

package org.radargun.stages.helpers;

import java.util.Collection;

import org.radargun.state.SlaveState;
import org.radargun.traits.Clustered;

public class RoleHelper {

   public enum Role {
      COORDINATOR
   }

   public final static String SUPPORTED_ROLES = "[COORDINATOR]";

   private RoleHelper() {}

   public static boolean hasAnyRole(SlaveState slaveState, Collection<Role> roles) {
      for (Role role : roles) {
         switch (role) {
            case COORDINATOR:
               Clustered clustered = slaveState.getTrait(Clustered.class);
               return clustered != null && clustered.isCoordinator();
         }
         throw new IllegalArgumentException("Role " + role + " is not supported");
      }
      return false;
   }
}
TOP

Related Classes of org.radargun.stages.helpers.RoleHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.