All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.partitionhandling.AvailabilityMode Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.partitionhandling;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Set;

import org.infinispan.commons.marshall.AbstractExternalizer;
import org.infinispan.commons.marshall.MarshallUtil;
import org.infinispan.commons.util.Util;
import org.infinispan.marshall.core.Ids;

/**
* @author Mircea Markus
* @author Dan Berindei
* @since 7.0
*/
public enum AvailabilityMode {

   /**
    * Regular operation mode
    */
   AVAILABLE,

   /**
    * Data can not be safely accessed because of a network split or successive nodes leaving.
    */
   DEGRADED_MODE;

   public AvailabilityMode min(AvailabilityMode other) {
      if (this == DEGRADED_MODE || other == DEGRADED_MODE)
         return DEGRADED_MODE;
      return AVAILABLE;
   }

   private static final AvailabilityMode[] CACHED_VALUES = values();

   public static AvailabilityMode valueOf(int ordinal) {
      return CACHED_VALUES[ordinal];
   }

   public static final class Externalizer extends AbstractExternalizer {
      @Override
      public Integer getId() {
         return Ids.AVAILABILITY_MODE;
      }

      @Override
      public Set> getTypeClasses() {
         return Util.asSet(AvailabilityMode.class);
      }

      @Override
      public void writeObject(ObjectOutput output, AvailabilityMode AvailabilityMode) throws IOException {
         MarshallUtil.marshallEnum(AvailabilityMode, output);
      }

      @Override
      public AvailabilityMode readObject(ObjectInput input) throws IOException {
         return MarshallUtil.unmarshallEnum(input, AvailabilityMode::valueOf);
      }
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy