private void removeWeakReferenceFromStmntMap(long stmntId, StmntWeakReference sRef) { assert Thread.holdsLock(this.stmntMap); if (this.stmntMap.get(stmntId) == sRef) { if (GemFireXDUtils.TraceQuery | GemFireXDUtils.TraceNCJ) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, "GfxdConnectionWrapper#removeWeakReferenceFromStmntMap: " + "removing statement with id: " + stmntId); this.stmntMap.remove(stmntId); } } }
public long addAndLoadStreamContainer(final long segmentId, final Properties tableProperties, final RowSource rowSource, final ByteBuffer rwBuffer) throws StandardException { if (SanityManager.DEBUG) { SanityManager.ASSERT( segmentId == StreamContainerHandle.TEMPORARY_SEGMENT, "GemFireTransaction: Must be only used for temporary file creations"); } final long conglomId = getNextTempConglomId(); if (this.tempCongloms == null) { this.tempCongloms = LongObjectHashMap.withExpectedSize(8); } this.tempCongloms.justPut(conglomId, new FileStreamInputOutput(conglomId, this, rowSource, rwBuffer)); return conglomId; }
if (this.stmntMap.size() > 0) { CollectStmts collectStmts = new CollectStmts(); this.stmntMap.forEachWhile(collectStmts); stmts = collectStmts.stmts; this.stmntMap.clear();
Object sr = this.stmntMap.get(stmtId); if (sr != null) { stmnt = ((StmntWeakReference)sr).get(); if (sql == null) { sql = (String)this.sqlMap.get(stmtId); if (sql == null) { throw new GemFireXDRuntimeException( stmnt = (EmbedStatement)getConnection().prepareCall(sql, stmtId); this.stmntMap.justPut(stmtId, new StmntWeakReference(stmnt, stmtId, this.refQueue)); if (!(defaultSchema != null && defaultSchema.equalsIgnoreCase(SystemProperties.SNAPPY_HIVE_METASTORE))) { this.sqlMap.justPut(stmtId, sql); "GfxdConnectionWrapper: cached PreparedStatement with stmtId=" + stmtId + " for connId=" + this.incomingConnId + " SQL: " + sql + ", for " + this + " SQLMapSize = "+ sqlMap.size()); this.stmntMap.justPut(stmtId, new StmntWeakReference(stmnt, stmtId, this.refQueue)); if (GemFireXDUtils.TraceQuery) {
static GfxdDDLMessage removePendingDDLMessage(final long ddlId) { synchronized (pendingDDLMessages) { return pendingDDLMessages.remove(ddlId); } }
new ArrayList<GfxdDDLMessage>(4); synchronized (pendingDDLMessages) { pendingDDLMessages.forEachWhile((ddlId, pendingMessage) -> { if (member.equals(pendingMessage.getSender())) { memberPendingMessages.add(pendingMessage); pendingDDLMessages.remove(ddlId);
/** * Test API only -- NOT THREAD-SAFE. */ public final EmbedStatement getStatementForTEST(long statementID) { if (this.stmntMap != null) { final Object sr = this.stmntMap.get(statementID); if (sr != null) { return ((StmntWeakReference)sr).get(); } } return null; }
this.tempCongloms.forEachWhile((key, val) -> { sb.append("temp conglomerate id = ").append(key).append(": ").append(val); return true;
isRemoteDDL, props); this.embedConn = conn; this.stmntMap = LongObjectHashMap.withExpectedSize(8); this.sqlMap = LongObjectHashMap.withExpectedSize(8); this.refQueue = new ReferenceQueue<EmbedStatement>();
/** * Close the wrapper clearing the Connection wrapper and cached statement map. */ public void close(final boolean closeEmbedConn, final boolean force) { final EmbedConnection conn = getEmbedConnection(); if (closeEmbedConn && conn != null && !conn.isActive()) { return; } if (GemFireXDUtils.TraceQuery | GemFireXDUtils.TraceNCJ) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_QUERYDISTRIB, "Closing connection: " + conn); } if (clearStatementMap()) { this.sqlMap.clear(); } if (closeEmbedConn && conn != null) { try { conn.close(false /* do not distribute */); } catch (Exception e) { if (force) { // ignore exception and close the connection forcibly conn.forceClose(); } else { throw GemFireXDRuntimeException.newRuntimeException( "GfxdConnectionWrapper#close: unexpected exception", e); } } } }
public void removeStmtFromMap(long stmntId) { if (this.stmntMap != null) { synchronized (this.stmntMap) { this.stmntMap.remove(stmntId); } } }
public StreamContainerHandle openStreamContainer(long segmentId, long containerId, boolean hold) throws StandardException { if (SanityManager.DEBUG) { SanityManager.ASSERT( segmentId == StreamContainerHandle.TEMPORARY_SEGMENT, "GemFireTransaction: Must be only used for temporary file creations"); } assert this.tempCongloms != null; final FileStreamInputOutput fc = (FileStreamInputOutput)this.tempCongloms .get(containerId); fc.flipToRead(); return fc; }
== TransactionController.IS_TEMPORARY) { if (this.tempCongloms == null) { this.tempCongloms = LongObjectHashMap.withExpectedSize(8); this.tempCongloms.justPut(conglomId, conglom);
public void dropStreamContainer(long segmentId, long containerId) throws StandardException { if (SanityManager.DEBUG) { SanityManager.ASSERT( segmentId == StreamContainerHandle.TEMPORARY_SEGMENT, "GemFireTransaction: Must be only used for temporary file creations"); } final FileStreamInputOutput container = (FileStreamInputOutput)this.tempCongloms .remove(containerId); if (SanityManager.DEBUG) { SanityManager.ASSERT(container != null, "GemFireTransaction: temporary sorted conglomerate must have been present " + containerId); } container.close(); }
public static MemConglomerate findConglomerate(final long conglomId, final LanguageConnectionContext lcc, final GemFireTransaction tran) throws StandardException { if (conglomId >= 0) { return Misc.getMemStore().findConglomerate( ContainerKey.valueOf(ContainerHandle.TABLE_SEGMENT, conglomId)); } MemConglomerate tempconglom = null; if (tran.tempCongloms != null) { tempconglom = (MemConglomerate)tran.tempCongloms.get(conglomId); } if (tempconglom == null) { tempconglom = lcc.getConglomerateForDeclaredGlobalTempTable(conglomId); } return tempconglom; }
public void closeStatement(long statementID) throws SQLException { Object stmt; synchronized (this.stmntMap) { stmt = this.stmntMap.remove(statementID); // also cleanup statement map cleanUpStmntMap(); } if (stmt != null) { EmbedStatement es = ((StmntWeakReference)stmt).get(); if (es != null) { final GemFireXDQueryObserver observer = GemFireXDQueryObserverHolder .getInstance(); es.close(); if (observer != null) { observer.afterClosingWrapperPreparedStatement(statementID, this.incomingConnId); } } } }
public EmbedStatement getStatementForCancellation(long stmtId, long executionId) { EmbedStatement stmnt = null; if (this.stmntMap != null) { synchronized (this.stmntMap) { // cleanup statement map first cleanUpStmntMap(); Object sr = this.stmntMap.get(stmtId); if (sr != null) { stmnt = ((StmntWeakReference)sr).get(); } // return null if the stmt is not active or the passed in executionId // does not match if (stmnt != null ) { if (!stmnt.isActive()) { return null; } // if executionId passed is non-zero then // match the executionId as well if (executionId != 0) { if (stmnt.getExecutionID() != executionId) { return null; } } } } } return stmnt; }
this.tempCongloms.remove(conglomId);