Reserve space in the log file.
We don't have to account for sector bytes because those were reserved at startup.

@param reservedDelta the change to the number of reserved bytes if this write is successful.
@throws ObjectManagerException
972592
protected void reserve(long reservedDelta)
                    throws ObjectManagerException
    {

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "reserve",
                        new Object[] { new Long(reservedDelta) }
                            );
        long unavailable = reserveLogFileSpace(reservedDelta);
        if (unavailable != 0) {
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass,
                           "reserve",
                           new Object[] { "via LogFileFullException", new Long(unavailable), new Long(reservedDelta) }
                                );
            throw new LogFileFullException(this
                                           , reservedDelta
                                           , reservedDelta
                                           , reservedDelta - unavailable);
        } // if (unavailable != 0).

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "reserve");
    }
370774
public void writeObject(DataOutputStream dataOutputStream) throws ObjectManagerException, IOException
    {
        super.writeObject(dataOutputStream);

        // Write out our serialVersionUID
        dataOutputStream.writeLong(serialVersionUID);

        if (_dataSlices != null)
        {
            // Write the number of slices we have
            dataOutputStream.writeInt(_dataSlices.size());
    
            // Write each slice out
            for (DataSlice slice : _dataSlices)
            {
                dataOutputStream.writeInt(slice.getLength());
                dataOutputStream.write(slice.getBytes(), slice.getOffset(), slice.getLength());
            }
        }
        else
        {
            // We have no slices so just write a 
            // zero so we don't try to read any in
            // at readObject time.
            dataOutputStream.writeInt(0);
        }
    }
909939
public synchronized void prepare(Transaction transaction)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
286510
private void setBatchSize(String persistenceUnit, Map<String, Object> puProperties) {
        String batch_Size = null;

        PersistenceUnitMetadata puMetadata =
            KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata, persistenceUnit);

        String externalBatchSize =
            puProperties != null ? (String) puProperties.get(PersistenceProperties.KUNDERA_BATCH_SIZE) : null;

        Integer intbatch = null;
        if (puMetadata.getBatchSize() > 0) {
            intbatch = new Integer(puMetadata.getBatchSize());
        }
        batch_Size =
            (String) (externalBatchSize != null ? externalBatchSize : intbatch != null ? intbatch.toString() : null);

        setBatchSize(batch_Size);
    }
133541
public void setReservedInstancesListings(java.util.Collection<ReservedInstancesListing> reservedInstancesListings) {
        if (reservedInstancesListings == null) {
            this.reservedInstancesListings = null;
            return;
        }

        this.reservedInstancesListings = new com.amazonaws.internal.SdkInternalList<ReservedInstancesListing>(reservedInstancesListings);
    }
365137
public Token allocate(ManagedObject objectToStore)
                    throws ObjectManagerException
    {

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "allocate",
                        objectToStore);

        // We cannot store null, it won't serialize and we have no way to manage the transaction state.
        if (objectToStore == null) {
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this,
                           cclass,
                           "allocate",
                           objectToStore);
            throw new InvalidObjectToStoreException(this,
                                                    objectToStore);
        } // If asked to store null.

        // Is the store full?
        if (!allocationAllowed) {
            // request or wait for a checkpoint and see if that helps
            if (getStoreFullWaitForCheckPoint())
            {
                if (trace.isDebugEnabled())
                    trace.debug(this, cclass, "allocate", "Store is currently full, waiting for checkpoint");
                objectManagerState.waitForCheckpoint(true);
            }
            else
            {
                if (trace.isDebugEnabled())
                    trace.debug(this, cclass, "allocate", "Store is currently full, requesting checkpoint");
                objectManagerState.requestCheckpoint(true);
            }

            if (!allocationAllowed)
            {
                if (trace.isEntryEnabled())
                    trace.exit(this, cclass
                               , "allocate"
                                    );

                throw new ObjectStoreFullException(this
                                                   , objectToStore);
            }
        } // If (!allocationAllowed). 

        Token tokenToStore;
        long usableSequenceNumber;

        synchronized (sequenceNumberLock) {
            // Establish the sequence number we will use. 
            usableSequenceNumber = ++sequenceNumber;
        } // synchronized (sequenceNumberLock).

        // Create the container for the object.    
        tokenToStore = new Token(objectToStore, this, usableSequenceNumber);

        // Keep a note of the in memory copy of the object so that we give back the same one
        // whenever it is asked for.
        // If the application never adds the object, we would clean this up when its reference to the Object
        // is lost. 
        Token inMemoryToken = (Token) inMemoryTokens.putIfAbsent(new Long(usableSequenceNumber),
                                                                 tokenToStore);

        // Check that this genuinely a new storedObjectIdentifier.
        if (inMemoryToken != null) {
            if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                trace.debug(this,
                            cclass,
                            "allocate",
                            new Object[] { "via StoreSequenceException",
                                          inMemoryToken,
                                          new Long(sequenceNumber) });
            StoreSequenceException storeSequenceException = new StoreSequenceException(this,
                                                                                       sequenceNumber,
                                                                                       inMemoryToken);
            ObjectManager.ffdc.processException(this,
                                                cclass,
                                                "add",
                                                storeSequenceException,
                                                "1:402:1.31");
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this,
                           cclass,
                           "allocate",
                           storeSequenceException);
            throw storeSequenceException;
        } // if (inMemoryToken != null).

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "allocate"
                       , new Object[] { tokenToStore }
                            );
        return tokenToStore;
    }
305264
public long size(Transaction transaction)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "size",
                        "Transaction=" + transaction);

        long totalSize = 0; // Size to return.
        for (int i = 0; i < subLists.length; i++) {
            totalSize = totalSize + subLists[i].size(transaction);
        } // for subLists.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "size",
                       "return=" + totalSize);
        return totalSize;
    }
975604
public final void writeObject(java.io.DataOutputStream dataOutputStream)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "writeObject",
                        new Object[] { dataOutputStream });

        try {
            dataOutputStream.writeByte(SimpleSerialVersion);
            super.writeObject(dataOutputStream);

            if (comparator == null) {
                dataOutputStream.writeByte(0);
            } else {
                dataOutputStream.writeByte(1);
                java.io.ObjectOutputStream objectOutputStream = new java.io.ObjectOutputStream(dataOutputStream);
                objectOutputStream.writeObject(comparator);
                objectOutputStream.close();
            } // if (head == null).
            if (root == null) {
                dataOutputStream.writeByte(0);
            } else {
                dataOutputStream.writeByte(1);
                root.writeObject(dataOutputStream);
            } // if (root == null).
            dataOutputStream.writeLong(size);

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, "writeObject", exception, "1:2341:1.44");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this,
                           cclass,
                           "writeObject",
                           exception);

            throw new PermanentIOException(this,
                                           exception);
        } // catch (java.io.IOException exception).

        // Did we exceed the size limits?
        // Check comparator did not cause us to exceed maximum serialized length.
        if (dataOutputStream.size() > maximumSerializedSize())
        {
            if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                trace.debug(this,
                            cclass,
                            "writeObject",
                            new Object[] { new Long(maximumSerializedSize()),
                                          new Integer(dataOutputStream.size()) });
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "writeObject"
                           , "via SimplifiedSerializationSizeException"
                                );

            throw new SimplifiedSerializationSizeException(this,
                                                           maximumSerializedSize(),
                                                           dataOutputStream.size());
        } // if (dataOutputStream.size() > maximumSerializedSize())    

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "writeObject");
    }
1311057
private void setEntityManagerPoolSize(String poolSize) {

        setExtProperty(
            CmsDbPoolV11.KEY_DATABASE_POOL + '.' + getPool() + '.' + CmsDbPoolV11.KEY_ENTITY_MANAGER_POOL_SIZE,
            poolSize);
    }
945224
void setServiceData(byte[] serviceData) throws InternalLogException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "setServiceData", new java.lang.Object[] { RLSUtils.toHexString(serviceData, RLSUtils.MAX_DISPLAY_BYTES), this });

        // Check that the files are available
        if ((_file1 == null) || (_file2 == null))
        {
            if (tc.isEntryEnabled())
                Tr.exit(tc, "setServiceData", "InternalLogException");
            throw new InternalLogException(null);
        }

        // Cache the service data buffer reference. This class logically 'owns' the buffer.
        _serviceData = serviceData;

        // Pass the reference to the underlying log file objects.
        _file1.setServiceData(serviceData);
        _file2.setServiceData(serviceData);

        if (tc.isEntryEnabled())
            Tr.exit(tc, "setServiceData");
    }
1144732
@Override
  protected void reserveInternal(int newCapacity) {
    int oldCapacity = (nulls == 0L) ? 0 : capacity;
    if (isArray() || type instanceof MapType) {
      this.lengthData =
          Platform.reallocateMemory(lengthData, oldCapacity * 4L, newCapacity * 4L);
      this.offsetData =
          Platform.reallocateMemory(offsetData, oldCapacity * 4L, newCapacity * 4L);
    } else if (type instanceof ByteType || type instanceof BooleanType) {
      this.data = Platform.reallocateMemory(data, oldCapacity, newCapacity);
    } else if (type instanceof ShortType) {
      this.data = Platform.reallocateMemory(data, oldCapacity * 2L, newCapacity * 2L);
    } else if (type instanceof IntegerType || type instanceof FloatType ||
        type instanceof DateType || DecimalType.is32BitDecimalType(type)) {
      this.data = Platform.reallocateMemory(data, oldCapacity * 4L, newCapacity * 4L);
    } else if (type instanceof LongType || type instanceof DoubleType ||
        DecimalType.is64BitDecimalType(type) || type instanceof TimestampType) {
      this.data = Platform.reallocateMemory(data, oldCapacity * 8L, newCapacity * 8L);
    } else if (childColumns != null) {
      // Nothing to store.
    } else {
      throw new RuntimeException("Unhandled " + type);
    }
    this.nulls = Platform.reallocateMemory(nulls, oldCapacity, newCapacity);
    Platform.setMemory(nulls + oldCapacity, (byte)0, newCapacity - oldCapacity);
    capacity = newCapacity;
  }
1096372
protected void saveClonedState(Transaction transaction)
                    throws ObjectManagerException {
        final String methodName = "saveClonedState";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, transaction);

        // Loop over all of the ObjecStores.
        java.util.Iterator objectStoreIterator = objectStores.values()
                        .iterator();
        while (objectStoreIterator.hasNext()) {
            ObjectStore objectStore = (ObjectStore) objectStoreIterator.next();

            // Don't bother with ObjectStores that can't be used for recovery.
            if (objectStore.getContainsRestartData()) {

                // Locate any existing copy.
                Token objectManagerStateCloneToken = new Token(objectStore,
                                                               ObjectStore.objectManagerStateIdentifier.longValue());
                // Swap for the definitive Token, if there is one.
                objectManagerStateCloneToken = objectStore.like(objectManagerStateCloneToken);

                ObjectManagerState objectManagerStateClone = (ObjectManagerState) objectManagerStateCloneToken.getManagedObject();

                // Does the cloned state already exist?
                if (objectManagerStateClone == null) {
                    objectManagerStateClone = new ObjectManagerState();
                    objectManagerStateClone.objectStores = objectStores;
                    objectManagerStateClone.becomeCloneOf(this);
                    objectManagerStateCloneToken.setManagedObject(objectManagerStateClone);
                    transaction.add(objectManagerStateClone);

                } else {
                    transaction.lock(objectManagerStateClone);
                    objectManagerStateClone.objectStores = objectStores;
                    objectManagerStateClone.becomeCloneOf(this);
                    transaction.replace(objectManagerStateClone);
                } //  if (objectManagerStateClone == null).
            } // if (objectStore.getContainsRestartData()).
        } // While objectStoreIterator.hasNext().

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName);
    }
546010
private void processResourceEnterpriseColumns(FieldMap fieldMap, Resource resource, Var2Data resourceVarData)
   {
      byte[] data = null;
      Integer varDataKey = fieldMap.getVarDataKey(ResourceField.ENTERPRISE_DATA);
      if (varDataKey != null)
      {
         data = resourceVarData.getByteArray(resource.getUniqueID(), varDataKey);
      }

      if (data != null)
      {
         PropsBlock props = new PropsBlock(data);
         //System.out.println(props);
         resource.setCreationDate(props.getTimestamp(Props.RESOURCE_CREATION_DATE));

         for (Integer key : props.keySet())
         {
            int keyValue = key.intValue() - MPPResourceField.RESOURCE_FIELD_BASE;
            //System.out.println("Key=" + keyValue);

            ResourceField field = MPPResourceField.getInstance(keyValue);

            if (field != null)
            {
               Object value = null;

               switch (field.getDataType())
               {
                  case CURRENCY:
                  {
                     value = Double.valueOf(props.getDouble(key) / 100);
                     break;
                  }

                  case DATE:
                  {
                     value = props.getTimestamp(key);
                     break;
                  }

                  case DURATION:
                  {
                     byte[] durationData = props.getByteArray(key);
                     double durationValueInHours = ((double) MPPUtility.getInt(durationData, 0)) / 600;
                     TimeUnit durationUnits;
                     if (durationData.length < 6)
                     {
                        durationUnits = TimeUnit.DAYS;
                     }
                     else
                     {
                        durationUnits = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(durationData, 4));
                     }
                     Duration duration = Duration.getInstance(durationValueInHours, TimeUnit.HOURS);
                     value = duration.convertUnits(durationUnits, m_file.getProjectProperties());
                     break;

                  }

                  case BOOLEAN:
                  {
                     switch (field)
                     {
                        case FLAG1:
                        {
                           field = null;
                           int bits = props.getInt(key);
                           resource.set(ResourceField.ENTERPRISE_FLAG1, Boolean.valueOf((bits & 0x00002) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG2, Boolean.valueOf((bits & 0x00004) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG3, Boolean.valueOf((bits & 0x00008) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG4, Boolean.valueOf((bits & 0x00010) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG5, Boolean.valueOf((bits & 0x00020) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG6, Boolean.valueOf((bits & 0x00040) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG7, Boolean.valueOf((bits & 0x00080) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG8, Boolean.valueOf((bits & 0x00100) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG9, Boolean.valueOf((bits & 0x00200) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG10, Boolean.valueOf((bits & 0x00400) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG11, Boolean.valueOf((bits & 0x00800) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG12, Boolean.valueOf((bits & 0x01000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG13, Boolean.valueOf((bits & 0x02000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG14, Boolean.valueOf((bits & 0x04000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG15, Boolean.valueOf((bits & 0x08000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG16, Boolean.valueOf((bits & 0x10000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG17, Boolean.valueOf((bits & 0x20000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG18, Boolean.valueOf((bits & 0x40000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG19, Boolean.valueOf((bits & 0x80000) != 0));
                           resource.set(ResourceField.ENTERPRISE_FLAG20, Boolean.valueOf((bits & 0x100000) != 0));
                           break;
                        }

                        case GENERIC:
                        {
                           field = null;
                           resource.setGeneric(props.getShort(key) != 0);
                           break;
                        }

                        default:
                        {
                           break;
                        }
                     }

                     break;
                  }

                  case NUMERIC:
                  {
                     value = Double.valueOf(props.getDouble(key));
                     break;
                  }

                  case STRING:
                  {
                     value = props.getUnicodeString(key);
                     break;
                  }

                  default:
                  {
                     break;
                  }
               }

               resource.set(field, value);
            }
         }
      }
   }
1029049
public synchronized void flush()
                    throws ObjectManagerException
    {
        final String methodName = "flush";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        methodName);

        if (storeStrategy == STRATEGY_SAVE_ONLY_ON_SHUTDOWN) {
            // Since we only flush on shutdown make sure we are shutting down, otherwise just return. 
            if (objectManagerState.getObjectManagerStateState() != ObjectManagerState.stateStopped) {
                if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                    trace.exit(this,
                               cclass,
                               methodName);
                return;
            }

            // If there are any active transactions it is not safe to flush.
            if (objectManagerState.getTransactionIterator().hasNext()) {
                trace.warning(this,
                              cclass,
                              methodName,
                              "ObjectStore_UnsafeToFlush",
                              this
                                );
                if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                    trace.exit(this,
                               cclass,
                               methodName);
                return;
            }
        } // if ( storeStrategy == STRATEGY_SAVE_ONLY_ON_SHUTDOWN ).

        // Debug freespace list
        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "START of Flush: newFreeSpace.size()      = "+newFreeSpace.size());
        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "START of Flush: freeSpaceByLength.size() = "+freeSpaceByLength.size());

        // We are single threaded through flush, we are now about to make
        // updates to the directory and free space map, which must be consistent.
        // Also reserve space in the file for the directory updates and free space map.
        updateDirectory();

        // Release any space into the free space pool.
        if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
            trace.debug(this,
                        cclass,
                        methodName,
                        "Release new free space");

        // Free up space that was release by directory changes, replaced or deleted Objects.
        freeAllocatedSpace(newFreeSpace);

        if (gatherStatistics) {
            long now = System.currentTimeMillis();
            releasingEntrySpaceMilliseconds += now - lastFlushMilliseconds;
            lastFlushMilliseconds = now;
        } // if (gatherStatistics).

        // Write the modified parts of the directory to disk.
        directory.write();

        if (gatherStatistics) {
            long now = System.currentTimeMillis();
            directoryWriteMilliseconds += now - lastFlushMilliseconds;
            lastFlushMilliseconds = now;
        } // if (gatherStatistics).

        // Write the free space map to disk.
        writeFreeSpace();

        // Force the data to disk then force the header, if we can make the assumption that
        // these writes go to disk first, this first force is unnecessary.
        if (storeStrategy == STRATEGY_KEEP_ALWAYS)
            force();

        writeHeader();
        if (storeStrategy == STRATEGY_KEEP_ALWAYS)
            force();

        // Debug freespace list
        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "END of Flush: newFreeSpace.size()      = "+newFreeSpace.size());
        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "END of Flush: freeSpaceByLength.size() = "+freeSpaceByLength.size());

        // Defect 573905
        // Reset the newFreeSpace after we have finished with it to release the
        // memory it uses while we are not flushing.
        newFreeSpace.clear();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       methodName);
    }
1039565
public void setRangePartitioned(Ordering ordering, DataDistribution distribution) {
		if (ordering == null) {
			throw new NullPointerException();
		}
		
		this.partitioning = PartitioningProperty.RANGE_PARTITIONED;
		this.ordering = ordering;
		this.partitioningFields = ordering.getInvolvedIndexes();
		this.distribution = distribution;
	}
427565
public synchronized void preDelete(Transaction transaction)
                    throws ObjectManagerException
    {
        final String methodName = "preDelete";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        methodName,
                        new Object[] { transaction });

        // The tree must be empty, apart from Entries this transaction will delete.
        Entry entry = null;
        if (root != null)
            entry = (Entry) AbstractTreeMap.minimum(getRoot());
        while (entry != null) {
            if (entry.willBeDeleted(transaction)) {
                entry = (Entry) successor(entry);
            } else {
                if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                    trace.exit(this, cclass,
                               methodName,
                               "via CollentionNotEmptyException"
                                               + "size=" + size + "(long)"
                                               + " entry.state=" + entry.state + "(int) " + Entry.stateNames[entry.state]
                                               + "\n entry.getTransactionLock=" + entry.getTransactionLock() + "(TransactionLock)"
                                    );

                throw new CollectionNotEmptyException(this, size, transaction);

            } // if (  entry.willBeDeleted...
        } // while (entry != null).

        super.preDelete(transaction); // Also takes a lock.
        // Visibility is now restricted to our transaction only.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName);
    }
1062146
protected void setLogFileSize(long newFileSize)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "setLogFileSize"
                        , "newFileSize=" + newFileSize + "(long)"
                            );

        // Note where we are in the log file.
        long initialFilePosition = filePosition;

        synchronized (newFileSizeRequestLock) {
            // Force the new file size to be a whole number of pages.
            this.newFileSize = (newFileSize / pageSize) * pageSize;
            newFileSizeRequested = true;
            newFileSizeException = null;
            logFileSizeRequested = newFileSize;
            // We have not yet seen the log file wrap.
            boolean wrapped = false;

            // Keep requesting checkpoints until the start and end of the log data are both 
            // before the new end of the log, without the user log data wrapping round the 
            // end of the logFile.
            while (newFileSizeRequested) {

                // Check there is still some chance of fitting the current log into the new one.
                // and that we have not wrapped round the log file without succeeding.
                long fileSpaceAvailable = getLogFileSpaceLeft();
                long newFileSpaceAvailable = fileSpaceAvailable - fileLogHeader.fileSize + newFileSize;
                float newOcupancy = (float) 1.0 - (float) (newFileSpaceAvailable) / (float) (newFileSize);
                if (newOcupancy > objectManagerState.logFullPostCheckpointThreshold
                    || wrapped) {
                    newFileSizeRequested = false;
                    logFileSizeRequested = 0;
                    if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                        trace.exit(this,
                                   cclass,
                                   "setLogFileSize",
                                   new Object[] { new Long(fileLogHeader.fileSize),
                                                 new Long(newFileSize),
                                                 new Float(newOcupancy) });
                    throw new LogFileSizeTooSmallException(this
                                                           , fileLogHeader.fileSize
                                                           , newFileSize
                                                           , fileSpaceAvailable
                                                           , newOcupancy
                                                           , objectManagerState.logFullPostCheckpointThreshold);
                } // if (   (fileSpaceLeft...

                if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                    trace.debug(this,
                                cclass,
                                "setLogFileSize",
                                new Object[] { new Long(filePosition),
                                              new Long(initialFilePosition) });

                // If we have wrapped round the log file, give up after the next attempt to satisfy the 
                // request. 
                if (filePosition < initialFilePosition)
                    wrapped = true;

                // We have released the lock on writingFlushSet set so now we can request a checkpoint and
                // see if we are successful.
                objectManagerState.waitForCheckpoint(true);

                // Speed up moving the filePosition by writing a reasonable ammount of data.
                // The folowing is dangerous because it can cause the request to fail if we 
                // are trying to reduce the log file size close to the minimum possible. 
//        PaddingLogRecord paddingLogRecord = new PaddingLogRecord(logBufferSize/2);
//        writeNext(paddingLogRecord
//                 ,0
//                 ,true
//                 );

            } // while (newFileSizeRequested...

            logFileSizeRequested = 0;
        } // synchronized (newFileSizeRequestLock).                                            

        if (newFileSizeException != null) {
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "setLogFileSize"
                           , "via PermanentIOException newFileSizeException=" + newFileSizeException + "(PermanentIOException)"
                                );
            throw newFileSizeException;
        }

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "setLogFileSize"
                            );
    }