/** {@inheritDoc} */ @Override protected void cleanup() { synchronized (this) { U.close(sock); sock = null; } } }
/** {@inheritDoc} */ @Override public void close() { U.closeQuiet(writer); U.close(dir, ctx.log(GridLuceneIndex.class)); }
/** */ public void onInterruption() { U.close(srvrSock, log); } }
/** * Called by connection bool on connection close. * * @param conn closed connection. */ private void closeDetachedConnection(H2ConnectionWrapper conn) { U.close(conn, log); detachedConns.remove(conn); }
/** {@inheritDoc} */ @Override public void close() throws Exception { if (streamers == null) return; for (IgniteDataStreamer<?, ?> s : streamers.values()) U.close(s, log); } }
/** * Called periodically to cleanup connections. */ private void cleanupConnections() { threadConns.entrySet().removeIf(e -> { Thread t = e.getKey(); if (t.getState() == Thread.State.TERMINATED) { e.getValue().keySet().forEach(c -> U.close(c, log)); return true; } return false; }); }
/** {@inheritDoc} */ @Override public void interrupt() { super.interrupt(); synchronized (this) { U.close(sock); sock = null; } }
/** * Closes and releases input stream. * * @param in Object input stream. */ static void closeIn(OptimizedObjectInputStream in) { U.close(in, null); if (inPool != null) { boolean b = inPool.offer(in); assert b; } else { StreamHolder holder = holders.get(); if (holder != null) holder.releaseIn(); } }
/** * Closes and releases output stream. * * @param out Object output stream. */ static void closeOut(OptimizedObjectOutputStream out) { U.close(out, null); if (outPool != null) { boolean b = outPool.offer(out); assert b; } else { StreamHolder holder = holders.get(); if (holder != null) holder.releaseOut(); } }
/** * Turn off streaming on this client context - with closing all open streamers, if any. */ public void disableStreaming() { synchronized (mux) { if (!isStream()) return; Iterator<IgniteDataStreamer<?, ?>> it = streamers.values().iterator(); while (it.hasNext()) { IgniteDataStreamer<?, ?> streamer = it.next(); U.close(streamer, log); it.remove(); } streamers = null; orderedBatchThread = null; } }
/** * Handles SQL exception. * @param c Connection to close. */ public void onSqlException(Connection c) { H2ConnectionWrapper conn = threadConn.get().object(); // Clear thread local cache if connection not detached. if (conn.connection() == c) threadConn.remove(); if (c != null) { threadConns.remove(Thread.currentThread()); // Reset connection to receive new one at next call. U.close(c, log); } }
/** {@inheritDoc} */ @Override protected <T> T unmarshal0(byte[] arr, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { GridByteArrayInputStream in = null; try { in = new GridByteArrayInputStream(arr, 0, arr.length); return unmarshal(in, clsLdr); } finally { U.close(in, null); } }
/** * Creates checkpoint table. * * @param conn Active database connection. * @throws SQLException Thrown in case of any errors. */ private void createCheckpointTable(Connection conn) throws SQLException { Statement st = null; try { st = conn.createStatement(); st.executeUpdate(crtTblSql); if (log.isDebugEnabled()) log.debug("Successfully created checkpoint table: " + tblName); } finally { U.close(st, log); } }
/** {@inheritDoc} */ @Override protected byte[] marshal0(@Nullable Object obj) throws IgniteCheckedException { GridByteArrayOutputStream out = null; try { out = new GridByteArrayOutputStream(DFLT_BUFFER_SIZE); marshal(obj, out); return out.toByteArray(); } finally { U.close(out, null); } }
@Override public TestObject apply() { Input kryoIn = null; try { kryoIn = new Input(new ByteArrayInputStream(out.toByteArray())); return kryo.readObject(kryoIn, TestObject.class); } finally { U.close(kryoIn, log); } } };
@Override public void apply(TestObject obj) { out.reset(); Output kryoOut = null; try { kryoOut = new Output(out); kryo.writeObject(kryoOut, obj); } finally { U.close(kryoOut, log); } } };
@Override public TestObject applyx() throws IgniteCheckedException { ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ObjectInputStream objIn = null; try { objIn = new ObjectInputStream(in); return (TestObject)objIn.readObject(); } catch (ClassNotFoundException | IOException e) { throw new IgniteCheckedException(e); } finally { U.close(objIn, log); } } };
@Override public void applyx(TestObject obj) throws IgniteCheckedException { out.reset(); ObjectOutputStream objOut = null; try { objOut = new ObjectOutputStream(out); objOut.writeObject(obj); } catch (IOException e) { throw new IgniteCheckedException(e); } finally { U.close(objOut, log); } } };
/** {@inheritDoc} */ @Override protected void onContextDestroyed0() { if (dataSrc != null) { Connection conn = null; try { conn = getConnection(); removeExpiredCheckpoints(conn); conn.commit(); } catch (SQLException e) { U.rollbackConnection(conn, log); U.error(log, "Failed to remove expired checkpoints from: " + tblName, e); //throw new GridSpiException("Failed to remove expired checkpoints from: " + tblName, e); } finally { U.close(conn, log); } } }
/** * @param node Grid node. * @throws IOException If write failed. */ private void writeObject(ClusterNode node) throws Exception { Marshaller marshaller = getTestResources().getMarshaller(); OutputStream out = new NullOutputStream(); try { marshaller.marshal(node, out); } finally { U.close(out, null); } }