View Javadoc

1   package org.apache.helix;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  public class Criteria
23  {
24    public enum DataSource
25    {
26      IDEALSTATES, EXTERNALVIEW
27    }
28    /**
29     * This can be CONTROLLER, PARTICIPANT, ROUTER Cannot be null
30     */
31    InstanceType recipientInstanceType;
32    /**
33     * If true this will only be process by the instance that was running when the
34     * message was sent. If the instance process dies and comes back up it will be
35     * ignored.
36     */
37    boolean sessionSpecific;
38    /**
39     * applicable only in case PARTICIPANT use * to broadcast to all instances
40     */
41    String instanceName = "";
42    /**
43     * Name of the resource. Use * to send message to all resources
44     * owned by an instance.
45     */
46    String resourceName = "";
47    /**
48     * Resource partition. Use * to send message to all partitions of a given
49     * resource
50     */
51    String partitionName = "";
52    /**
53     * State of the resource
54     */
55    String partitionState = "";
56    /**
57     * Exclude sending message to your self. True by default
58     */
59    boolean selfExcluded = true;
60    /**
61     * Determine if use external view or ideal state as source of truth
62     */
63    DataSource _dataSource = DataSource.EXTERNALVIEW;
64    
65    public DataSource getDataSource()
66    {
67      return _dataSource;
68    }
69    
70    public void setDataSource(DataSource source)
71    {
72      _dataSource = source;
73    }
74  
75    public boolean isSelfExcluded()
76    {
77      return selfExcluded;
78    }
79  
80    public void setSelfExcluded(boolean selfExcluded)
81    {
82      this.selfExcluded = selfExcluded;
83    }
84  
85    public InstanceType getRecipientInstanceType()
86    {
87      return recipientInstanceType;
88    }
89  
90    public void setRecipientInstanceType(InstanceType recipientInstanceType)
91    {
92      this.recipientInstanceType = recipientInstanceType;
93    }
94  
95    public boolean isSessionSpecific()
96    {
97      return sessionSpecific;
98    }
99  
100   public void setSessionSpecific(boolean sessionSpecific)
101   {
102     this.sessionSpecific = sessionSpecific;
103   }
104 
105   public String getInstanceName()
106   {
107     return instanceName;
108   }
109 
110   public void setInstanceName(String instanceName)
111   {
112     this.instanceName = instanceName;
113   }
114 
115   public String getResource()
116   {
117     return resourceName;
118   }
119 
120   public void setResource(String resourceName)
121   {
122     this.resourceName = resourceName;
123   }
124 
125   public String getPartition()
126   {
127     return partitionName;
128   }
129 
130   public void setPartition(String partitionName)
131   {
132     this.partitionName = partitionName;
133   }
134 
135   public String getPartitionState()
136   {
137     return partitionState;
138   }
139 
140   public void setPartitionState(String partitionState)
141   {
142     this.partitionState = partitionState;
143   }
144 
145   public String toString()
146   {
147     StringBuilder sb = new StringBuilder();
148     sb.append("instanceName").append("=").append(instanceName);
149     sb.append("resourceName").append("=").append(resourceName);
150     sb.append("partitionName").append("=").append(partitionName);
151     sb.append("partitionState").append("=").append(partitionState);
152     return sb.toString();
153   }
154 
155 }