Tabnine Logo
DataUtils.newIllegalStateException
Code IndexAdd Tabnine to your IDE (free)

How to use
newIllegalStateException
method
in
org.h2.mvstore.DataUtils

Best Java code snippets using org.h2.mvstore.DataUtils.newIllegalStateException (Showing top 20 results out of 315)

origin: com.h2database/h2

private void checkOpen() {
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,
        "This store is closed", panicException);
  }
}
origin: com.h2database/h2

/**
 * Check whether this transaction is open or prepared.
 */
void checkNotClosed() {
  if (status == STATUS_CLOSED) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_CLOSED, "Transaction is closed");
  }
}
origin: com.h2database/h2

@Override
public final Object read(ByteBuffer buff) {
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,
      "Internal error");
}
origin: com.h2database/h2

/**
 * Flush all changes.
 */
public void sync() {
  try {
    file.force(true);
  } catch (IOException e) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_WRITING_FAILED,
        "Could not sync file {0}", fileName, e);
  }
}
origin: com.h2database/h2

/**
 * Add an element at the end.
 *
 * @param obj the element
 */
public synchronized void add(K obj) {
  if (obj == null) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_INTERNAL, "adding null value to list");
  }
  int len = array.length;
  array = Arrays.copyOf(array, len + 1);
  array[len] = obj;
}
origin: com.h2database/h2

/**
 * Get the block.
 *
 * @param key the key
 * @return the block
 */
byte[] getBlock(long key) {
  byte[] data = map.get(key);
  if (data == null) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_BLOCK_NOT_FOUND,
        "Block {0} not found",  key);
  }
  return data;
}
origin: com.h2database/h2

/**
 * Parse an unsigned, hex long.
 *
 * @param x the string
 * @return the parsed value
 * @throws IllegalStateException if parsing fails
 */
public static int parseHexInt(String x) {
  try {
    // avoid problems with overflow
    // in Java 8, we can use Integer.parseLong(x, 16);
    return (int) Long.parseLong(x, 16);
  } catch (NumberFormatException e) {
    throw newIllegalStateException(ERROR_FILE_CORRUPT,
        "Error parsing the value {0}", x, e);
  }
}
origin: com.h2database/h2

/**
 * Truncate the file.
 *
 * @param size the new file size
 */
public void truncate(long size) {
  try {
    writeCount.incrementAndGet();
    file.truncate(size);
    fileSize = Math.min(fileSize, size);
  } catch (IOException e) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_WRITING_FAILED,
        "Could not truncate file {0} to size {1}",
        fileName, size, e);
  }
}
origin: com.h2database/h2

@Override
public void free(long pos, int length) {
  freeSpace.free(pos, length);
  ByteBuffer buff = memory.remove(pos);
  if (buff == null) {
    // nothing was written (just allocated)
  } else if (buff.remaining() != length) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_READING_FAILED,
        "Partial remove is not supported at position {0}", pos);
  }
}
origin: com.h2database/h2

/**
 * Write to a file channel.
 *
 * @param file the file channel
 * @param pos the absolute position within the file
 * @param src the source buffer
 */
public static void writeFully(FileChannel file, long pos, ByteBuffer src) {
  try {
    int off = 0;
    do {
      int len = file.write(src, pos + off);
      off += len;
    } while (src.remaining() > 0);
  } catch (IOException e) {
    throw newIllegalStateException(
        ERROR_WRITING_FAILED,
        "Writing to {0} failed; length {1} at {2}",
        file, src.remaining(), pos, e);
  }
}
origin: com.h2database/h2

/**
 * Parse an unsigned, hex long.
 *
 * @param x the string
 * @return the parsed value
 * @throws IllegalStateException if parsing fails
 */
public static long parseHexLong(String x) {
  try {
    if (x.length() == 16) {
      // avoid problems with overflow
      // in Java 8, this special case is not needed
      return (Long.parseLong(x.substring(0, 8), 16) << 32) |
          Long.parseLong(x.substring(8, 16), 16);
    }
    return Long.parseLong(x, 16);
  } catch (NumberFormatException e) {
    throw newIllegalStateException(ERROR_FILE_CORRUPT,
        "Error parsing the value {0}", x, e);
  }
}
origin: com.h2database/h2

@Override
public ByteBuffer readFully(long pos, int len) {
  Entry<Long, ByteBuffer> memEntry = memory.floorEntry(pos);
  if (memEntry == null) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_READING_FAILED,
        "Could not read from position {0}", pos);
  }
  readCount.incrementAndGet();
  readBytes.addAndGet(len);
  ByteBuffer buff = memEntry.getValue();
  ByteBuffer read = buff.duplicate();
  int offset = (int) (pos - memEntry.getKey());
  read.position(offset);
  read.limit(len + offset);
  return read.slice();
}
origin: com.h2database/h2

/**
 * Close this store.
 */
public void close() {
  try {
    if (fileLock != null) {
      fileLock.release();
      fileLock = null;
    }
    file.close();
    freeSpace.clear();
  } catch (Exception e) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_WRITING_FAILED,
        "Closing failed for file {0}", fileName, e);
  } finally {
    file = null;
  }
}
origin: com.h2database/h2

private void loadChunkMeta() {
  // load the chunk metadata: we can load in any order,
  // because loading chunk metadata might recursively load another chunk
  for (Iterator<String> it = meta.keyIterator("chunk."); it.hasNext();) {
    String s = it.next();
    if (!s.startsWith("chunk.")) {
      break;
    }
    s = meta.get(s);
    Chunk c = Chunk.fromString(s);
    if (chunks.putIfAbsent(c.id, c) == null) {
      if (c.block == Long.MAX_VALUE) {
        throw DataUtils.newIllegalStateException(
            DataUtils.ERROR_FILE_CORRUPT,
            "Chunk {0} is invalid", c.id);
      }
    }
  }
}
origin: com.h2database/h2

/**
 * Get the chunk for the given position.
 *
 * @param pos the position
 * @return the chunk
 */
private Chunk getChunk(long pos) {
  Chunk c = getChunkIfFound(pos);
  if (c == null) {
    int chunkId = DataUtils.getPageChunkId(pos);
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_FILE_CORRUPT,
        "Chunk {0} not found", chunkId);
  }
  return c;
}
origin: com.h2database/h2

/**
 * This method is called before writing to the map. The default
 * implementation checks whether writing is allowed, and tries
 * to detect concurrent modification.
 *
 * @throws UnsupportedOperationException if the map is read-only,
 *      or if another thread is concurrently writing
 */
protected void beforeWrite() {
  if (closed) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_CLOSED, "This map is closed");
  }
  if (readOnly) {
    throw DataUtils.newUnsupportedOperationException(
        "This map is read-only");
  }
  store.beforeWrite(this);
}
origin: com.h2database/h2

/**
 * Remove a log entry.
 *
 * @param t the transaction
 * @param logId the log id
 */
public void logUndo(Transaction t, long logId) {
  Long undoKey = getOperationId(t.getId(), logId);
  rwLock.writeLock().lock();
  try {
    Object[] old = undoLog.remove(undoKey);
    if (old == null) {
      throw DataUtils.newIllegalStateException(
          DataUtils.ERROR_TRANSACTION_ILLEGAL_STATE,
          "Transaction {0} was concurrently rolled back",
          t.getId());
    }
  } finally {
    rwLock.writeLock().unlock();
  }
}
origin: com.h2database/h2

private V set(K key, V value) {
  transaction.checkNotClosed();
  V old = get(key);
  boolean ok = trySet(key, value, false);
  if (ok) {
    return old;
  }
  throw DataUtils.newIllegalStateException(
      DataUtils.ERROR_TRANSACTION_LOCKED, "Entry is locked");
}
origin: com.h2database/h2

/**
 * Unlink the children recursively after all data is written.
 */
void writeEnd() {
  if (isLeaf()) {
    return;
  }
  int len = children.length;
  for (int i = 0; i < len; i++) {
    PageReference ref = children[i];
    if (ref.page != null) {
      if (ref.page.getPos() == 0) {
        throw DataUtils.newIllegalStateException(
            DataUtils.ERROR_INTERNAL, "Page not written");
      }
      ref.page.writeEnd();
      children[i] = new PageReference(null, ref.pos, ref.count);
    }
  }
}
origin: com.h2database/h2

/**
 * Write the chunk header.
 *
 * @param buff the target buffer
 * @param minLength the minimum length
 */
void writeChunkHeader(WriteBuffer buff, int minLength) {
  long pos = buff.position();
  buff.put(asString().getBytes(StandardCharsets.ISO_8859_1));
  while (buff.position() - pos < minLength - 1) {
    buff.put((byte) ' ');
  }
  if (minLength != 0 && buff.position() > minLength) {
    throw DataUtils.newIllegalStateException(
        DataUtils.ERROR_INTERNAL,
        "Chunk metadata too long");
  }
  buff.put((byte) '\n');
}
org.h2.mvstoreDataUtilsnewIllegalStateException

Javadoc

Create a new IllegalStateException.

Popular methods of DataUtils

  • readVarInt
    Read a variable size int.
  • appendMap
    Append a map to the string builder, sorted by key.
  • checkArgument
    Throw an IllegalArgumentException if the argument is invalid.
  • copyExcept
    Copy the elements of an array, and remove one element.
  • copyWithGap
    Copy the elements of an array, with a gap.
  • encodeLength
    Convert the length to a length code 0..31. 31 means more than 1 MB.
  • formatMessage
    Format an error message.
  • getCheckValue
    Calculate a check value for the given integer. A check value is mean to verify the data is consisten
  • getErrorCode
    Get the error code from an exception message.
  • getFletcher32
    Calculate the Fletcher32 checksum.
  • getPageChunkId
    Get the chunk id from the position.
  • getPageMaxLength
    Get the maximum length for the given code. For the code 31, PAGE_LARGE is returned.
  • getPageChunkId,
  • getPageMaxLength,
  • getPageOffset,
  • getPagePos,
  • getPageType,
  • getVarIntLen,
  • initCause,
  • newIllegalArgumentException,
  • newUnsupportedOperationException

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Notification (javax.management)
  • JCheckBox (javax.swing)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now