Clover coverage report - ActiveCluster - 1.1-SNAPSHOT
Coverage timestamp: Tue May 24 2005 08:48:28 BST
file stats: LOC: 148   Methods: 10
NCLOC: 60   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ClusterEvent.java 0% 0% 0% 0%
coverage
 1   
 /** 
 2   
  * 
 3   
  * Copyright 2004 Protique Ltd
 4   
  * 
 5   
  * Licensed under the Apache License, Version 2.0 (the "License"); 
 6   
  * you may not use this file except in compliance with the License. 
 7   
  * You may obtain a copy of the License at 
 8   
  * 
 9   
  * http://www.apache.org/licenses/LICENSE-2.0
 10   
  * 
 11   
  * Unless required by applicable law or agreed to in writing, software
 12   
  * distributed under the License is distributed on an "AS IS" BASIS, 
 13   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 14   
  * See the License for the specific language governing permissions and 
 15   
  * limitations under the License. 
 16   
  * 
 17   
  **/
 18   
 
 19   
 package org.activecluster;
 20   
 import java.io.Externalizable;
 21   
 import java.io.IOException;
 22   
 import java.io.ObjectInput;
 23   
 import java.io.ObjectOutput;
 24   
 
 25   
 /**
 26   
  * A cluster event
 27   
  * 
 28   
  * @version $Revision: 1.1 $
 29   
  */
 30   
 public class ClusterEvent implements Externalizable {
 31   
     /**
 32   
      * A node has joined the cluster
 33   
      */
 34   
     public static final int ADD_NODE = 1;
 35   
     /**
 36   
      * existing node has updated it's state
 37   
      */
 38   
     public static final int UPDATE_NODE = 2;
 39   
     /**
 40   
      * A node has left the Cluster
 41   
      */
 42   
     public static final int REMOVE_NODE = 3;
 43   
     /**
 44   
      * A node has failed due to a system/network error
 45   
      */
 46   
     public static final int FAILED_NODE = 4;
 47   
     
 48   
     /**
 49   
      * this node has been elected Coordinator
 50   
      */
 51   
     public static final int ELECTED_COORDINATOR = 5;
 52   
     
 53   
     private transient Cluster cluster;
 54   
     private Node node;
 55   
     private int type;
 56   
 
 57   
     /**
 58   
      * empty constructor
 59   
      */
 60  0
     public ClusterEvent() {
 61   
     }
 62   
 
 63   
     /**
 64   
      * @param source
 65   
      * @param node
 66   
      * @param type
 67   
      */
 68  0
     public ClusterEvent(Cluster source, Node node, int type) {
 69  0
         this.cluster = source;
 70  0
         this.node = node;
 71  0
         this.type = type;
 72   
     }
 73   
 
 74   
     /**
 75   
      * @return the Cluster
 76   
      */
 77  0
     public Cluster getCluster() {
 78  0
         return cluster;
 79   
     }
 80   
 
 81   
     /**
 82   
      * set the cluster
 83   
      * @param source
 84   
      */
 85  0
     public void setCluster(Cluster source){
 86  0
         this.cluster = source;
 87   
     }
 88   
     /**
 89   
      * @return the node
 90   
      */
 91  0
     public Node getNode() {
 92  0
         return node;
 93   
     }
 94   
 
 95   
     /**
 96   
      * @return the type of event
 97   
      */
 98  0
     public int getType() {
 99  0
         return type;
 100   
     }
 101   
 
 102   
     /**
 103   
      * @return pretty type
 104   
      */
 105  0
     public String toString() {
 106  0
         return "ClusterEvent[" + getTypeAsString() + " : " + node + "]";
 107   
     }
 108   
 
 109   
     /**
 110   
      * dump on to a stream
 111   
      * 
 112   
      * @param out
 113   
      * @throws IOException
 114   
      */
 115  0
     public void writeExternal(ObjectOutput out) throws IOException {
 116  0
         out.writeByte(type);
 117  0
         out.writeObject(node);
 118   
     }
 119   
 
 120   
     /**
 121   
      * read from stream
 122   
      * 
 123   
      * @param in
 124   
      * @throws IOException
 125   
      * @throws ClassNotFoundException
 126   
      */
 127  0
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
 128  0
         type = in.readByte();
 129  0
         node = (Node) in.readObject();
 130   
     }
 131   
 
 132  0
     private String getTypeAsString() {
 133  0
         String result = "unknown type";
 134  0
         if (type == ADD_NODE) {
 135  0
             result = "ADD_NODE";
 136   
         }
 137  0
         else if (type == REMOVE_NODE) {
 138  0
             result = "REMOVE_NODE";
 139   
         }
 140  0
         else if (type == UPDATE_NODE) {
 141  0
             result = "UPDATE_NODE";
 142   
         }
 143  0
         else if (type == FAILED_NODE) {
 144  0
             result = "FAILED_NODE";
 145   
         }
 146  0
         return result;
 147   
     }
 148   
 }