private boolean isTableLocked(final PathName typePath) { final String path = getCatalogPath(typePath); return Maps.getCount(this.tableWriteLockCountsByCatalogPath, path) > 0; }
@Override public String toUrl(final Map<String, Object> urlParameters) { final StringBuilder url = new StringBuilder("jdbc:postgresql:"); final String host = Maps.getString(urlParameters, "host"); final Integer port = Maps.getInteger(urlParameters, "port"); final String database = Maps.getString(urlParameters, "database"); final boolean hasHost = Property.hasValue(host); final boolean hasPort = port != null; if (hasHost || hasPort) { url.append("//"); if (hasHost) { url.append(host); } if (hasPort) { url.append(':'); url.append(port); } url.append('/'); } if (Property.hasValue(database)) { url.append(database); } return url.toString(); } }
@Override public String toUrl(final Map<String, Object> urlParameters) { final String file = Maps.getString(urlParameters, "file"); if (Property.hasValue(file)) { try { return FileUtil.toUrlString(file); } catch (final Throwable e) { return null; } } return null; } }
public boolean closeTable(final PathName typePath) { synchronized (this.apiSync) { final String path = getCatalogPath(typePath); int count = Maps.getInteger(this.tableReferenceCountsByCatalogPath, path, 0); count--; if (count <= 0) {
public synchronized CoordinateSystem getCoordinateSystem(final int oracleSrid) { CoordinateSystem coordinateSystem = this.oracleCoordinateSystems.get(oracleSrid); if (coordinateSystem == null) { try { final Map<String, Object> result = JdbcUtils.selectMap(this, "SELECT * FROM MDSYS.SDO_CS_SRS WHERE SRID = ?", oracleSrid); if (result == null) { coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(oracleSrid); } else { final String wkt = (String)result.get("WKTEXT"); coordinateSystem = WktCsParser.read(wkt); coordinateSystem = EpsgCoordinateSystems.getCoordinateSystem(coordinateSystem); } } catch (final Throwable e) { Logs.error(this, "Unable to load coordinate system: " + oracleSrid, e); return null; } this.oracleCoordinateSystems.put(oracleSrid, coordinateSystem); } return coordinateSystem; }
protected Table getTableWithWriteLock(final RecordDefinition recordDefinition) { synchronized (this.apiSync) { final Table table = getTable(recordDefinition); if (table != null) { final String catalogPath = getCatalogPath(recordDefinition); final Integer count = Maps.addCount(this.tableWriteLockCountsByCatalogPath, catalogPath); if (count == 1) { table.setWriteLock(); table.setLoadOnlyMode(true); } } return table; } }
/** * Release the record store for the file. Decrements the count of references to the file. If * the count <=0 then the record store will be removed. * * @param fileName * @return True if the record store has no references and was released. False otherwise */ static boolean release(final FileGdbRecordStore recordStore) { synchronized (COUNTS) { final String fileName = recordStore.getFileName(); final FileGdbRecordStore currentRecordStore = RECORD_STORES.get(fileName); if (currentRecordStore == recordStore) { final AtomicInteger countHolder = Maps.get(COUNTS, fileName, new AtomicInteger()); final int count = countHolder.decrementAndGet(); if (count <= 0) { COUNTS.remove(fileName); RECORD_STORES.remove(fileName); return true; } } else { return !recordStore.isClosed(); } } return false; }
protected void releaseTable(final String catalogPath) { synchronized (this.apiSync) { final Geodatabase geodatabase = getGeodatabase(); if (geodatabase != null) { try { final Table table = this.tableByCatalogPath.get(catalogPath); if (table != null) { final Integer count = Maps.decrementCount(this.tableReferenceCountsByCatalogPath, catalogPath); if (count == 0) { try { this.tableByCatalogPath.remove(catalogPath); this.tableWriteLockCountsByCatalogPath.remove(catalogPath); geodatabase.closeTable(table); } catch (final Exception e) { Logs.error(this, "Unable to close table: " + catalogPath, e); } finally { if (this.tableByCatalogPath.isEmpty()) { this.geodatabaseReferenceCount--; } table.delete(); } } } } finally { releaseGeodatabase(); } } } }
@Override public String toUrl(final Map<String, Object> urlParameters) { final StringBuilder url = new StringBuilder("jdbc:oracle:thin:@"); final String namedConnection = Maps.getString(urlParameters, "namedConnection"); if (Property.hasValue(namedConnection)) { url.append(namedConnection.toLowerCase()); } else { final String host = Maps.getString(urlParameters, "host"); final Integer port = Maps.getInteger(urlParameters, "port"); final String database = Maps.getString(urlParameters, "database");
public static FileGdbRecordStore newRecordStore(final File file) { if (file == null) { return null; } else { synchronized (COUNTS) { final String fileName = FileUtil.getCanonicalPath(file); final AtomicInteger count = Maps.get(COUNTS, fileName, new AtomicInteger()); count.incrementAndGet(); FileGdbRecordStore recordStore = RECORD_STORES.get(fileName); if (recordStore == null || recordStore.isClosed()) { recordStore = new FileGdbRecordStore(file); RECORD_STORES.put(fileName, recordStore); } return recordStore; } } }
protected void releaseTableAndWriteLock(final String catalogPath) { synchronized (this.apiSync) { final Geodatabase geodatabase = getGeodatabase(); if (geodatabase != null) { try { final Table table = this.tableByCatalogPath.get(catalogPath); if (table != null) { final Integer count = Maps.decrementCount(this.tableWriteLockCountsByCatalogPath, catalogPath); if (count == 0) { try { table.setLoadOnlyMode(false); table.freeWriteLock(); } catch (final Exception e) { Logs.error(this, "Unable to free write lock for table: " + catalogPath, e); } } } releaseTable(catalogPath); } finally { releaseGeodatabase(); } } } }