View Javadoc

1   package org.apache.jcs.auxiliary.lateral;
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  import java.io.Serializable;
23  
24  import org.apache.jcs.engine.behavior.ICacheElement;
25  
26  /***
27   * This class wraps command to other laterals. It is essentially a
28   * JCS-TCP-Lateral packet. The headers specify the action the receiver should
29   * take.
30   */
31  public class LateralElementDescriptor
32      implements Serializable
33  {
34      private static final long serialVersionUID = 5268222498076063575L;
35  
36      /*** The int for updates */
37      public final static int UPDATE = 1;
38  
39      /*** The int for removes */
40      public final static int REMOVE = 2;
41  
42      /*** The int instructing us to remove all */
43      public final static int REMOVEALL = 3;
44  
45      /*** The int for disposing the cache. */
46      public final static int DISPOSE = 4;
47  
48      /*** Command to return an object. */
49      public final static int GET = 5;
50  
51      /*** The Cache Element that we are distributing. */
52      public ICacheElement ce;
53  
54      /***
55       * The id of the the source of the request. This is used to prevent infinite
56       * loops.
57       */
58      public long requesterId;
59  
60      /*** The operation has been requested by the client. */
61      public int command = UPDATE;
62  
63      /***
64       * The hashcode value for this element.
65       */
66      public int valHashCode = -1;
67  
68      /*** Constructor for the LateralElementDescriptor object */
69      public LateralElementDescriptor()
70      {
71          super();
72      }
73  
74      /***
75       * Constructor for the LateralElementDescriptor object
76       * <p>
77       * @param ce ICacheElement payload
78       */
79      public LateralElementDescriptor( ICacheElement ce )
80      {
81          this.ce = ce;
82      }
83  
84      /***
85       * @return String, all the important values that can be configured
86       */
87      public String toString()
88      {
89          StringBuffer buf = new StringBuffer();
90          buf.append( "\n LateralElementDescriptor " );
91          buf.append( "\n command = [" + this.command + "]" );
92          buf.append( "\n valHashCode = [" + this.valHashCode + "]" );
93          buf.append( "\n ICacheElement = [" + this.ce + "]" );
94          return buf.toString();
95      }
96  }