Examples of VRecordMap


Examples of com.sun.messaging.jmq.io.VRecordMap

            recordMap = new ConcurrentHashMap(mSize);
        }

  Iterator iter = entries.iterator();
  while (iter.hasNext()) {
      VRecordMap record = (VRecordMap)iter.next();

      Object key = null;
      Object value = null;
      Throwable kex = null;
      Throwable vex = null;
      Throwable ex = null;
      try {
                ByteBuffer buffer = record.getBuffer();
                buffer.position(0);
                int limit = buffer.limit();
                byte[] data = new byte[limit];
                buffer.get(data);
                ByteArrayInputStream bais = new ByteArrayInputStream(data);

                // Use our version of ObjectInputStream so we can load old
                // serialized object from an old store, i.e. store migration
                ObjectInputStream ois = new MQObjectInputStream(bais);
        try {
        key = ois.readObject();
        } catch (Throwable e) {
        if (e instanceof ClassNotFoundException) {
      throw (ClassNotFoundException)e;
        } else {
      kex = e;
        }
    }

    try {
        value = ois.readObject();
    } catch (Throwable e) {
        if (e instanceof ClassNotFoundException) {
      throw (ClassNotFoundException)e;
        } else {
      vex = e;
        }
    }

                // Mark client data starting position
                if (maxClientDataSize > 0) {
                    // Since we've read in all data in the buffer, we need to
                    // reset the position back to client data starting position
                    int pos = limit - bais.available();
                    buffer.position(pos);
                    buffer.mark();
                }

    ois.close();
    bais.close();
      } catch (IOException e) {
    ex = e;
      }

      if (kex != null || vex != null || ex != null) {

    PHashMapLoadException le = new PHashMapLoadException(
                    "Failed to load data in [" + record.toString() + "]");
    le.setKey(key);
    le.setValue(value);
    le.setKeyCause(kex);
    le.setValueCause(vex);
    le.setNextException(loadException);
View Full Code Here

Examples of com.sun.messaging.jmq.io.VRecordMap

                // Add addtional space for client data and marker
                // to indicate the existence of client data
                dataLength += maxClientDataSize + CLIENT_DATA_MARKER.length;
            }

            VRecordMap record = (VRecordMap)recordMap.get(key);

            synchronized (backingFile) {
                if (record == null) {
                    record = (VRecordMap)backingFile.allocate(dataLength);
                } else {
                    if (record.getDataCapacity() < dataLength) {
                        // need another VRecordMap
                        backingFile.free(record);
                        record = (VRecordMap)backingFile.allocate(dataLength);
                    }
                }
                MappedByteBuffer buffer = (MappedByteBuffer)record.getBuffer();
                buffer.rewind();
                buffer.put(data);

                // Mark client data starting position
                if (maxClientDataSize > 0) {
                    buffer.mark();

                    // Clear the old data by removing the old's marker
                    buffer.put(EMPTY_CLIENT_DATA_MARKER);

                    // Now, resets buffer's to starting position of client data
                    buffer.reset();
                }

                if (safe) {
                    record.force();
                }
            }

            // update internal records map
            recordMap.put(key, record);
View Full Code Here

Examples of com.sun.messaging.jmq.io.VRecordMap

                "Client data size of " + cData.length +
                " bytes is larger than the byte limit (maxClientDataSize) of " +
                maxClientDataSize + " [key=" + key + ", cData=" + cData + "]");
        }

        VRecordMap record = (VRecordMap)recordMap.get(key);
        if (record == null) {
            throw new IllegalStateException(
                "Record not found [key=" + key + ", cData=" + cData + "]");
        }

        try {
            synchronized (backingFile) {
                // Just update the client data portion of the record
                MappedByteBuffer buffer = (MappedByteBuffer)record.getBuffer();

                try {
                    // Resets buffer's to starting position of client data
                    buffer.reset();
                } catch (InvalidMarkException e) {
                    // Try to reset the marker
                    setClientDataMarker(buffer);
                }

                buffer.put(CLIENT_DATA_MARKER); // Put marker
                buffer.put(cData);              // Put client data

                if (safe) {
                    record.force();
                }
            }

            // update internal HashMap
            recordMap.put(key, record);
View Full Code Here

Examples of com.sun.messaging.jmq.io.VRecordMap

        byte[] cData = null;

        // load client data if available
        try {
            if (maxClientDataSize > 0) {
                VRecordMap record = (VRecordMap)recordMap.get(key);
                if (record != null) {
                    synchronized (backingFile) {
                        ByteBuffer buffer = record.getBuffer();

                        // Resets buffer's to starting position of client data
                        try {
                            buffer.reset();
                        } catch (InvalidMarkException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.