<commit_before>/*
 * Cacheonix Systems licenses this file to You under the LGPL 2.1
 * (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *      http://www.cacheonix.org/products/cacheonix/license-lgpl-2.1.htm
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cacheonix.impl.cache.distributed.partitioned;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.cacheonix.CacheonixException;
import org.cacheonix.cache.CacheStatistics;
import org.cacheonix.impl.RuntimeIOException;
import org.cacheonix.impl.cache.item.Binary;
import org.cacheonix.impl.cache.item.InvalidObjectException;
import org.cacheonix.impl.cache.store.BinaryEntryModifiedSubscriber;
import org.cacheonix.impl.cache.store.BinaryStore;
import org.cacheonix.impl.cache.store.PreviousValue;
import org.cacheonix.impl.cache.store.ReadableElement;
import org.cacheonix.impl.cache.store.SharedCounter;
import org.cacheonix.impl.clock.Clock;
import org.cacheonix.impl.clock.Time;
import org.cacheonix.impl.config.LeaseConfiguration;
import org.cacheonix.impl.net.serializer.SerializerUtils;
import org.cacheonix.impl.net.serializer.Wireable;
import org.cacheonix.impl.net.serializer.WireableBuilder;
import org.cacheonix.impl.util.IOUtils;
import org.cacheonix.impl.util.logging.Logger;

/**
 * Bucket
 * <p/>
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @noinspection NonFinalFieldReferenceInEquals, RedundantIfStatement, ParameterNameDiffersFromOverriddenParameter
 * @since Aug 3, 2009 10:28:35 PM
 */
public final class Bucket implements Wireable {

   /**
    * Builder used by WireableFactory.
    */
   public static final WireableBuilder BUILDER = new Builder();

   /**
    * Logger.
    *
    * @noinspection UNUSED_SYMBOL, UnusedDeclaration
    */
   private static final Logger LOG = Logger.getLogger(Bucket.class); // NOPMD

   private transient volatile boolean reconfiguring = false;

   private final transient ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

   /**
    * Bucket number.
    */
   private int bucketNumber = 0;

   /**
    * The configuration parameter <code>lease duration</code> in millis.
    *
    * @see LeaseConfiguration#getLeaseTimeMillis()
    */
   private long leaseDurationMillis = 0L;

   /**
    * Expiration time of the read lease.
    */
   private Time leaseExpirationTime = null;

   /**
    * Key store.
    */
   private BinaryStore keyStore = null;


   /**
    * Required by Externalizable.<commit_msg>Fixed PMD report 'Avoid unused private fields such as 'lock''<commit_after>/*
 * Cacheonix Systems licenses this file to You under the LGPL 2.1
 * (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *      http://www.cacheonix.org/products/cacheonix/license-lgpl-2.1.htm
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cacheonix.impl.cache.distributed.partitioned;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.cacheonix.CacheonixException;
import org.cacheonix.cache.CacheStatistics;
import org.cacheonix.impl.RuntimeIOException;
import org.cacheonix.impl.cache.item.Binary;
import org.cacheonix.impl.cache.item.InvalidObjectException;
import org.cacheonix.impl.cache.store.BinaryEntryModifiedSubscriber;
import org.cacheonix.impl.cache.store.BinaryStore;
import org.cacheonix.impl.cache.store.PreviousValue;
import org.cacheonix.impl.cache.store.ReadableElement;
import org.cacheonix.impl.cache.store.SharedCounter;
import org.cacheonix.impl.clock.Clock;
import org.cacheonix.impl.clock.Time;
import org.cacheonix.impl.config.LeaseConfiguration;
import org.cacheonix.impl.net.serializer.SerializerUtils;
import org.cacheonix.impl.net.serializer.Wireable;
import org.cacheonix.impl.net.serializer.WireableBuilder;
import org.cacheonix.impl.util.IOUtils;
import org.cacheonix.impl.util.logging.Logger;

/**
 * Bucket
 * <p/>
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @noinspection NonFinalFieldReferenceInEquals, RedundantIfStatement, ParameterNameDiffersFromOverriddenParameter
 * @since Aug 3, 2009 10:28:35 PM
 */
public final class Bucket implements Wireable {

   /**
    * Builder used by WireableFactory.
    */
   public static final WireableBuilder BUILDER = new Builder();

   /**
    * Logger.
    *
    * @noinspection UNUSED_SYMBOL, UnusedDeclaration
    */
   private static final Logger LOG = Logger.getLogger(Bucket.class); // NOPMD

   private transient volatile boolean reconfiguring = false;

   /**
    * Bucket number.
    */
   private int bucketNumber = 0;

   /**
    * The configuration parameter <code>lease duration</code> in millis.
    *
    * @see LeaseConfiguration#getLeaseTimeMillis()
    */
   private long leaseDurationMillis = 0L;

   /**
    * Expiration time of the read lease.
    */
   private Time leaseExpirationTime = null;

   /**
    * Key store.
    */
   private BinaryStore keyStore = null;


   /**
    * Required by Externalizable.
{'fraction_non_alphanumeric': 0.09894978667541844, 'fraction_numerical': 0.005579258286839514, 'mean_word_length': 4.182823129251701, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3522307', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1791, 'n_words': 469}