Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.cache.persistence.soplog;
import java.io.File;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedOplog.SortedOplogReader;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedOplog.SortedOplogWriter;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedOplogSetImpl.MergedIterator;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedReader.Metadata;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedReader.SerializedComparator;
import com.gemstone.gemfire.internal.cache.persistence.soplog.SortedReader.SortedIterator;
import com.gemstone.gemfire.internal.util.AbortableTaskService;
import com.gemstone.gemfire.internal.util.AbortableTaskService.AbortableTask;
import com.gemstone.gemfire.internal.util.LogService;
public abstract class AbstractCompactor> implements Compactor {
/** the logger */
protected final ComponentLogWriter logger;
/** the soplog factory */
protected final SortedOplogFactory factory;
/** the fileset */
protected final Fileset fileset;
/** the soplog tracker */
protected final CompactionTracker tracker;
/** thread for background compaction */
protected final AbortableTaskService compactor;
/** inactive files waiting to be deleted */
private final Queue> inactive;
/** the soplogs */
protected final List levels;
/** provides consistent view of all levels */
private final ReadWriteLock levelLock;
/** test flag to abort compaction */
volatile boolean testAbortDuringCompaction;
/** test flag to delay compaction */
volatile CountDownLatch testDelayDuringCompaction;
public AbstractCompactor(SortedOplogFactory factory,
Fileset fileset, CompactionTracker tracker,
Executor exec) {
assert factory != null;
assert fileset != null;
assert tracker != null;
assert exec != null;
this.factory = factory;
this.fileset = fileset;
this.tracker = tracker;
compactor = new AbortableTaskService(exec);
inactive = new ConcurrentLinkedQueue>();
levelLock = new ReentrantReadWriteLock();
levels = new ArrayList();
logger = ComponentLogWriter.getSoplogLogWriter(factory.getConfiguration().getName(), LogService.logger());
}
@Override
public final void add(SortedOplog soplog) throws IOException {
levels.get(0).add(soplog);
}
@Override
public final boolean compact() throws IOException {
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference