Example usage for java.util.concurrent.locks ReentrantReadWriteLock ReentrantReadWriteLock

List of usage examples for java.util.concurrent.locks ReentrantReadWriteLock ReentrantReadWriteLock

Introduction

In this page you can find the example usage for java.util.concurrent.locks ReentrantReadWriteLock ReentrantReadWriteLock.

Prototype

public ReentrantReadWriteLock() 

Source Link

Document

Creates a new ReentrantReadWriteLock with default (nonfair) ordering properties.

Usage

From source file:org.alfresco.repo.content.metadata.MetadataExtracterRegistry.java

public MetadataExtracterRegistry() {
    // initialise lists
    extracters = new ArrayList<MetadataExtracter>(10);
    extracterCache = new HashMap<String, List<MetadataExtracter>>(17);
    embedderCache = new HashMap<String, List<MetadataEmbedder>>(17);

    // create lock objects for access to the cache
    ReadWriteLock extractionCacheLock = new ReentrantReadWriteLock();
    extracterCacheReadLock = extractionCacheLock.readLock();
    extracterCacheWriteLock = extractionCacheLock.writeLock();
}

From source file:org.apache.tajo.master.QueryInProgress.java

public QueryInProgress(TajoMaster.MasterContext masterContext, Session session, QueryContext queryContext,
        QueryId queryId, String sql, String jsonExpr, LogicalRootNode plan) {

    this.masterContext = masterContext;
    this.session = session;
    this.queryId = queryId;
    this.plan = plan;

    queryInfo = new QueryInfo(queryId, queryContext, sql, jsonExpr);
    queryInfo.setStartTime(System.currentTimeMillis());

    rpcParams = RpcParameterFactory.get(masterContext.getConf());

    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    this.readLock = readWriteLock.readLock();
    this.writeLock = readWriteLock.writeLock();
}

From source file:com.microsoft.tfs.core.clients.framework.location.internal.LocationCacheManager.java

public LocationCacheManager(final PersistenceStore cacheStore, GUID serverGuid, final URI serverUrl) {
    final ServerMap serverMap = ServerMap.load(cacheStore);

    /*//w ww  .  j a va2 s  .  c  o  m
     * If the given server GUID was empty, try to look it up in the
     * registration server map using the given URI.
     */
    if (serverGuid.equals(GUID.EMPTY)) {
        final String instanceID = serverMap.getServerID(serverUrl.toString());

        if (instanceID != null) {
            serverGuid = new GUID(instanceID);
        }
    }

    cacheAvailable = serverGuid.equals(GUID.EMPTY) ? false : true;
    cacheLocallyFresh = false;

    accessLock = new ReentrantReadWriteLock();
    lastChangeID = -1;

    mapAccessMappings = new HashMap<String, AccessMapping>();
    mapServices = new HashMap<String, Map<GUID, ServiceDefinition>>();
    connectionBaseUri = serverUrl;

    // Get the store for the location cache.
    if (cacheAvailable) {
        if (serverGuid != null) {
            final String directoryName = serverGuid.getGUIDString().toLowerCase() + "_" //$NON-NLS-1$
                    + connectionBaseUri.getScheme();
            locationDiskStore = cacheStore.getChildStore(CACHE_DIRECTORY_NAME).getChildStore(directoryName);
        }
    }
}

From source file:com.eatthepath.gtfs.TransitSystem.java

protected TransitSystem(final String id, final FeedInfo feedInfo, final Map<String, Agency> agenciesById,
        final Map<String, Stop> stopsById, final Map<String, Route> routesById,
        final Map<String, ServiceSchedule> serviceSchedulesById, final List<URL> realtimeUrls) {
    this.id = id;

    this.feedInfo = feedInfo;

    this.agenciesById = agenciesById;
    this.stopsById = stopsById;
    this.routesById = routesById;
    this.serviceSchedulesById = serviceSchedulesById;

    this.realtimeUrls = realtimeUrls;

    final ArrayList<Stop> freestandingStops = new ArrayList<Stop>();

    for (final Stop stop : this.stopsById.values()) {
        if (stop.getParentStation() == null) {
            freestandingStops.add(stop);
        }/*from  w w w .  j a  v  a 2 s .  co m*/
    }

    this.routesByStop = new HashMap<Stop, List<Route>>();
    this.tripsById = new HashMap<String, Trip>();

    for (final Route route : this.routesById.values()) {
        for (final Stop stop : route.getStopsServed()) {
            if (!this.routesByStop.containsKey(stop)) {
                this.routesByStop.put(stop, new ArrayList<Route>());
            }

            this.routesByStop.get(stop).add(route);

            for (final Trip trip : route.getTrips()) {
                this.tripsById.put(trip.getId(), trip);
            }
        }
    }

    this.stopTree = new VPTree<Stop>(freestandingStops);

    this.realtimeDataLock = new ReentrantReadWriteLock();

    this.realtimeFeedTimestamps = new HashMap<URL, Long>();

    this.vehiclesById = new HashMap<String, Vehicle>();
    this.vehiclesByRoute = new HashMap<Route, List<Vehicle>>();
    this.vehiclesByTrip = new HashMap<Trip, List<Vehicle>>();
}

From source file:org.videolan.vlc.MediaLibrary.java

private MediaLibrary() {
    mInstance = this;
    mItemList = new ArrayList<MediaWrapper>();
    mUpdateHandler = new ArrayList<Handler>();
    mItemListLock = new ReentrantReadWriteLock();
}

From source file:io.github.mkjung.ivi.media.MediaLibrary.java

private MediaLibrary() {
    mInstance = this;
    mItemList = new ArrayList<>();
    mUpdateHandler = new ArrayList<>();
    mItemListLock = new ReentrantReadWriteLock();
}

From source file:org.nuxeo.runtime.model.impl.ComponentPersistence.java

public ComponentPersistence(OSGiRuntimeService runtime) {
    this.runtime = runtime;
    root = new File(Environment.getDefault().getData(), "components");
    fileLock = new ReentrantReadWriteLock();
    sysrc = runtime.getContext();//from  w  ww  .  ja  v a 2 s.  c  o  m
    persistedComponents = Collections.synchronizedSet(new HashSet<>());
}

From source file:org.darkware.wpman.security.ChecksumDatabase.java

/**
 * Create a new {@code ChecksumDatabase} for files under the declared root and using the
 * given file for saved state./*from   w  ww  .j a  va  2s. c o m*/
 *
 * @param dbFile The file to load and store the database data into.
 * @param root  The highest level directory represented in the database.
 */
public ChecksumDatabase(final Path dbFile, final Path root) {
    super();

    this.root = root;
    this.dbFile = dbFile;
    this.hashes = new ConcurrentSkipListMap<>();
    this.suppressed = new ConcurrentSkipListSet<>();
    this.initialized = new AtomicBoolean(false);
    this.lock = new ReentrantReadWriteLock();

    this.initialize();
}

From source file:org.apache.ambari.server.state.action.ActionImpl.java

public ActionImpl(ActionId id, long startTime) {
    super();//www.  ja  v a  2 s.  com
    this.id = id;
    this.stateMachine = stateMachineFactory.make(this);
    ReadWriteLock rwLock = new ReentrantReadWriteLock();
    this.readLock = rwLock.readLock();
    this.writeLock = rwLock.writeLock();
    this.startTime = startTime;
    this.lastUpdateTime = -1;
    this.completionTime = -1;
}