Package com.nokia.dempsy

Examples of com.nokia.dempsy.DempsyException


      @Override
      public Destination selectDestinationForMessage(Object messageKey, Object message) throws DempsyException
      {
         Destination[] destinationArr = destinations.get();
         if (destinationArr == null)
            throw new DempsyException("It appears the Outbound strategy for the message key " +
                  SafeString.objectDescription(messageKey) + " is being used prior to initialization.");
         int length = destinationArr.length;
         if (length == 0)
            return null;
         int calculatedModValue = Math.abs(messageKey.hashCode()%length);
View Full Code Here


   }

   protected ClusterDefinition setParentApplicationDefinition(ApplicationDefinition applicationDef) throws DempsyException
   {
      if (clusterName == null)
         throw new DempsyException("You must set the 'clusterName' when configuring a dempsy cluster for the application: " + String.valueOf(applicationDef));
      clusterId = new ClusterId(applicationDef.getApplicationName(),clusterName);
      parent = applicationDef;
      return this;
   }
View Full Code Here

   }
  
   public void validate() throws DempsyException
   {
      if (parent == null)
         throw new DempsyException("The parent ApplicationDefinition isn't set for the Cluster " +
               SafeString.valueOf(clusterName) + ". You need to initialize the parent ApplicationDefinition prior to validating");
      if (clusterName == null)
         throw new DempsyException("You must set the 'clusterName' when configuring a dempsy cluster for the application.");
      if (messageProcessorPrototype == null && adaptor == null)
         throw new DempsyException("A dempsy cluster must contain either an 'adaptor' or a message processor prototype. " +
               clusterId + " doesn't appear to be configure with either.");
      if (messageProcessorPrototype != null && adaptor != null)
         throw new DempsyException("A dempsy cluster must contain either an 'adaptor' or a message processor prototype but not both. " +
               clusterId + " appears to be configured with both.");

     
      if (messageProcessorPrototype != null)
      {
         if(!messageProcessorPrototype.getClass().isAnnotationPresent(MessageProcessor.class))
            throw new DempsyException("Attempting to set an instance of \"" +
                  SafeString.valueOfClass(messageProcessorPrototype) + "\" within the " +
                  ClusterDefinition.class.getSimpleName() + " for \"" + SafeString.valueOf(clusterId) +
                  "\" but it isn't identified as a MessageProcessor. Please annotate the class.");

         Method[] methods = messageProcessorPrototype.getClass().getMethods();
        
         boolean foundAtLeastOneMethod = false;
         for(Method method: methods)
         {
            if(method.isAnnotationPresent(MessageHandler.class))
            {
               foundAtLeastOneMethod = true;
               break;
            }
         }
        
         if (!foundAtLeastOneMethod)
            throw new DempsyException("No method on the message processor of type \"" +
                  SafeString.valueOfClass(messageProcessorPrototype) + "\" is identified as a MessageHandler. Please annotate the appropriate method using @MessageHandler.");

         int startMethods = 0;
         for(Method method: methods)
         {
            if (method.isAnnotationPresent(Start.class))
            {
               startMethods++;
            }
         }
         if (startMethods > 1)
            throw new DempsyException("Multiple methods on the message processor of type\""
                  + SafeString.valueOf(messageProcessorPrototype) + "\" is identified as a Start method. Please annotate at most one method using @Start.");
     
         Method[] evictableMethods = messageProcessorPrototype.getClass().getMethods();
        
         boolean foundEvictableMethod = false;
         Method evictableMethod = null;
         for(Method method: evictableMethods)
         {
            if(method.isAnnotationPresent(Evictable.class))
            {
               if(foundEvictableMethod)
               {
                  throw new DempsyException("More than one method on the message processor of type \"" +
                        SafeString.valueOfClass(messageProcessorPrototype) + "\" is identified as a Evictable. Please annotate the appropriate method using @Evictable.");
               }
               foundEvictableMethod = true;
               evictableMethod = method;
            }
         }
         if(evictableMethod != null)
         {
            if(evictableMethod.getReturnType() == null || !evictableMethod.getReturnType().isAssignableFrom(boolean.class))
               throw new DempsyException("Evictable method \""+ SafeString.valueOf(evictableMethod) + "\" on the message processor of type \"" +
                     SafeString.valueOfClass(messageProcessorPrototype) + "\" should return boolean value. Please annotate the appropriate method using @Evictable.");
         }
      }
      if(adaptor != null && keySource != null)
      {
         throw new DempsyException("A dempsy cluster can not pre-instantation an adaptor.");
      }
   }
View Full Code Here

      if (!isInitialized)
      {
         for (ClusterDefinition clusterDef : clusterDefinitions)
         {
            if (clusterDef == null)
               throw new DempsyException("The application definition for \"" + applicationName + "\" has a null ClusterDefinition.");

            clusterDef.setParentApplicationDefinition(this);
         }
     
         isInitialized = true;
View Full Code Here

   public void validate() throws DempsyException
   {
      initialize();
     
      if (applicationName == null)
         throw new DempsyException("You must set the application name while configuring a Dempsy application.");
     
      if (clusterDefinitions == null || clusterDefinitions.size() == 0)
         throw new DempsyException("The application \"" + SafeString.valueOf(applicationName) + "\" doesn't have any clusters defined.");
     
      Set<ClusterId> clusterNames = new HashSet<ClusterId>();
        
      for (ClusterDefinition clusterDef : clusterDefinitions)
      {
         if (clusterDef == null)
            throw new DempsyException("The application definition for \"" + applicationName + "\" has a null ClusterDefinition.");
        
         if (clusterNames.contains(clusterDef.getClusterId()))
            throw new DempsyException("The application definition for \"" + applicationName + "\" has two cluster definitions with the name \"" + clusterDef.getClusterId().getMpClusterName() + "\"");
        
         clusterNames.add(clusterDef.getClusterId());
        
         clusterDef.validate();
      }
View Full Code Here

      ClusterDefinition currentClusterDef = null;
      if (currentCluster != null)
      {
         currentClusterDef = defs.get(currentCluster);
         if (currentClusterDef == null)
            throw new DempsyException("This Dempsy instance seems to be misconfigured. While this VM thinks it's an instance of " +
                  currentCluster + " the application it's configured with doesn't contain this cluster definition. The application configuration consists of: " +
                  applicationDefinition);
      }

      // get the set of explicit destinations if they exist
      Set<ClusterId> explicitClusterDestinations =
            (currentClusterDef != null && currentClusterDef.hasExplicitDestinations()) ? new HashSet<ClusterId>() : null;
      if (explicitClusterDestinations != null)
         explicitClusterDestinations.addAll(Arrays.asList(currentClusterDef.getDestinations()));

      //-------------------------------------------------------------------------------------
      // TODO: This loop will eventually be replaced when the instantiation of the Outbound
      // is driven from cluster information management events (Zookeeper callbacks).
      //-------------------------------------------------------------------------------------
      // if the currentCluster is set and THAT cluster has explicit destinations
      //  then those are the only ones we want to consider
      for (ClusterDefinition clusterDef : applicationDefinition.getClusterDefinitions())
      {
         if ((explicitClusterDestinations == null || explicitClusterDestinations.contains(clusterDef.getClusterId()))
               && !clusterDef.isRouteAdaptorType())
         {
            RoutingStrategy strategy = (RoutingStrategy)clusterDef.getRoutingStrategy();
            ClusterId clusterId = clusterDef.getClusterId();
            if (strategy == null)
               throw new DempsyException("Could not retrieve the routing strategy for " + SafeString.valueOf(clusterId));
           
            // This create will result in a callback on the Router as the Outbound.Coordinator with a
            // registration event. The Outbound may (will) call back on the Router to retrieve the
            // MpClusterSession and register itself with the appropriate cluster.
            outbounds.add(strategy.createOutbound(this, mpClusterSession,clusterId));
View Full Code Here

      sb.append("           see: http://zookeeper.apache.org/doc/r3.2.2/api/org/apache/zookeeper/ZooKeeper.html#ZooKeeper%28java.lang.String,%20int,%20org.apache.zookeeper.Watcher%29\n");
      sb.append("    -D" + total_slots_per_clusterParam + " Should specify the total number of address bins for hashing the messages. Please read the Dempsy Users Guide for details. If not specified the default is " + total_slots_per_clusterDefault + "\n");
      sb.append("    -D" + min_num_nodes_per_clusterParam + " Should specify the minumum number of nodes required for this cluster. Please read the Dempsy Users Guide for details. If not specified the default is " + min_num_nodes_per_clusterDefault + "\n");
     
      logger.error(MarkerFactory.getMarker("FATAL"), sb.toString());
      throw new DempsyException(sb.toString());
   }
View Full Code Here

      sb.append("           OR ");
      sb.append("    -D" + applicationParam + " must be supplied to indicate the Dempsy application name defined in spring application context xml file.\n");
      sb.append("           A file with the name DempsyApplicationContext-${applicaitonName}.xml that contains a spring applicaiton context xml must be on the classpath.");
     
      logger.error(MarkerFactory.getMarker("FATAL"), sb.toString());
      throw new DempsyException(sb.toString());
   }
View Full Code Here

TOP

Related Classes of com.nokia.dempsy.DempsyException

Copyright © 2018 www.massapicom. 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.