View Javadoc
1   package org.apache.commons.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 org.apache.commons.jcs.engine.behavior.ICacheElement;
23  
24  import java.io.Serializable;
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<K, V>
32      implements Serializable
33  {
34      /** Don't change */
35      private static final long serialVersionUID = 5268222498076063575L;
36  
37      /** The Cache Element that we are distributing. */
38      public ICacheElement<K, V> ce;
39  
40      /**
41       * The id of the the source of the request. This is used to prevent infinite
42       * loops.
43       */
44      public long requesterId;
45  
46      /** The operation has been requested by the client. */
47      public LateralCommand command = LateralCommand.UPDATE;
48  
49      /**
50       * The hashcode value for this element.
51       */
52      public int valHashCode = -1;
53  
54      /** Constructor for the LateralElementDescriptor object */
55      public LateralElementDescriptor()
56      {
57          super();
58      }
59  
60      /**
61       * Constructor for the LateralElementDescriptor object
62       * <p>
63       * @param ce ICacheElement&lt;K, V&gt; payload
64       */
65      public LateralElementDescriptor( ICacheElement<K, V> ce )
66      {
67          this.ce = ce;
68      }
69  
70      /**
71       * @return String, all the important values that can be configured
72       */
73      @Override
74      public String toString()
75      {
76          StringBuilder buf = new StringBuilder();
77          buf.append( "\n LateralElementDescriptor " );
78          buf.append( "\n command = [" + this.command + "]" );
79          buf.append( "\n valHashCode = [" + this.valHashCode + "]" );
80          buf.append( "\n ICacheElement = [" + this.ce + "]" );
81          return buf.toString();
82      }
83  }