当前位置: 首页>>代码示例>>Java>>正文


Java U.close方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.close方法的典型用法代码示例。如果您正苦于以下问题:Java U.close方法的具体用法?Java U.close怎么用?Java U.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.typedef.internal.U的用法示例。


在下文中一共展示了U.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resourceAvailable

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Checks availability of a classpath resource.
 *
 * @param name Resource name.
 * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
 */
private boolean resourceAvailable(String name) {
    InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);

    if (cfgStream == null) {
        log.error("Classpath resource not found: " + name);

        return false;
    }

    try {
        // Read a single byte to force actual content access by JVM.
        cfgStream.read();

        return true;
    }
    catch (IOException e) {
        log.error("Failed to read classpath resource: " + name, e);

        return false;
    }
    finally {
        U.close(cfgStream, log);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:CacheHibernateBlobStore.java

示例2: isResourceExist

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Check is class can be reached.
 *
 * @param ldr Class loader.
 * @param clsName Class name.
 * @return {@code true} if class can be loaded.
 */
private boolean isResourceExist(ClassLoader ldr, String clsName) {
    String rsrc = clsName.replaceAll("\\.", "/") + ".class";

    InputStream in = null;

    try {
        in = ldr instanceof GridUriDeploymentClassLoader ?
            ((GridUriDeploymentClassLoader)ldr).getResourceAsStreamGarOnly(rsrc) :
            ldr.getResourceAsStream(rsrc);

        return in != null;
    }
    finally {
        U.close(in, log);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:UriDeploymentSpi.java

示例3: createCheckpointTable

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:JdbcCheckpointSpi.java

示例4: getMessage

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Gets keyed message.
 *
 * @param key Message key.
 * @return Keyed message.
 */
@Nullable public String getMessage(String key) {
    InputStream in = null;

    try {
        in = getClass().getClassLoader().getResourceAsStream(RESOURCE);

        Properties props = new Properties();

        props.load(in);

        return props.getProperty(key);
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    finally {
        U.close(in, null);
    }

    return null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:GarHelloWorldBean.java

示例5: isCheckpointExists

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Checks specified checkpoint existing.
 *
 * @param conn Active jdbc connection.
 * @param key Checkpoint key.
 * @return {@code true} if specified checkpoint exists in the checkpoint table.
 * @throws SQLException Thrown in case of any errors.
 */
private boolean isCheckpointExists(Connection conn, String key) throws SQLException {
    PreparedStatement st = null;

    ResultSet rs = null;

    try {
        st = conn.prepareStatement(chkExistsSql);

        st.setString(1, key);

        rs = st.executeQuery();

        return rs.next();
    }
    finally {
        U.close(rs, log);
        U.close(st, log);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:JdbcCheckpointSpi.java

示例6: getMessage

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @return Value of the property {@code test1.txt} loaded from the {@code test2.properties} file.
 */
public String getMessage() {
    InputStream in = null;

    try {
        in = getClass().getClassLoader().getResourceAsStream(RESOURCE);

        Properties props = new Properties();

        props.load(in);

        return props.getProperty("test1.txt");
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    finally{
        U.close(in, null);
    }

    return null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridUriDeploymentDependency2.java

示例7: isCheckpointTableExists

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * This method accomplishes RDBMS-independent table exists check.
 *
 * @param conn Active database connection.
 * @return {@code true} if specified table exists, {@code false} otherwise.
 */
private boolean isCheckpointTableExists(Connection conn) {
    Statement st = null;

    ResultSet rs = null;

    try {
        st = conn.createStatement();

        rs = st.executeQuery(chkTblExistsSql);

        return true; // if table does exist, no rows will ever be returned
    }
    catch (SQLException ignored) {
        return false; // if table does not exist, an exception will be thrown
    }
    finally {
        U.close(rs, log);
        U.close(st, log);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:JdbcCheckpointSpi.java

示例8: createCheckpoint

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Creates checkpoint.
 *
 * @param conn Active database connection.
 * @param key Checkpoint key.
 * @param state Checkpoint data.
 * @param expTime Checkpoint expire time.
 * @return Number of rows affected by query.
 * @throws SQLException Thrown in case of any errors.
 */
private int createCheckpoint(Connection conn, String key, byte[] state, Time expTime) throws SQLException {
    PreparedStatement st = null;

    try {
        st = conn.prepareStatement(insSql);

        st.setString(1, key);
        st.setBytes(2, state);
        st.setTime(3, expTime);

        return st.executeUpdate();
    }
    finally {
        U.close(st, log);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:JdbcCheckpointSpi.java

示例9: connectionForThread

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Gets DB connection.
 *
 * @param schema Whether to set schema for connection or not.
 * @return DB connection.
 * @throws IgniteCheckedException In case of error.
 */
private Connection connectionForThread(@Nullable String schema) throws IgniteCheckedException {
    H2ConnectionWrapper c = connCache.get();

    if (c == null)
        throw new IgniteCheckedException("Failed to get DB connection for thread (check log for details).");

    if (schema != null && !F.eq(c.schema(), schema)) {
        Statement stmt = null;

        try {
            stmt = c.connection().createStatement();

            stmt.executeUpdate("SET SCHEMA " + H2Utils.withQuotes(schema));

            if (log.isDebugEnabled())
                log.debug("Set schema: " + schema);

            c.schema(schema);
        }
        catch (SQLException e) {
            throw new IgniteSQLException("Failed to set schema for DB connection for thread [schema=" +
                schema + "]", e);
        }
        finally {
            U.close(stmt, log);
        }
    }

    return c.connection();
}
 
开发者ID:apache,项目名称:ignite,代码行数:38,代码来源:IgniteH2Indexing.java

示例10: writeObject

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:AbstractDiscoverySelfTest.java

示例11: readBlock

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Read block from file.
 *
 * @param file - File to read.
 * @param off - Marker position in file to start read from if {@code -1} read last blockSz bytes.
 * @param blockSz - Maximum number of chars to read.
 * @param lastModified - File last modification time.
 * @return Read file block.
 * @throws IOException In case of error.
 */
public static VisorFileBlock readBlock(File file, long off, int blockSz, long lastModified) throws IOException {
    RandomAccessFile raf = null;

    try {
        long fSz = file.length();
        long fLastModified = file.lastModified();

        long pos = off >= 0 ? off : Math.max(fSz - blockSz, 0);

        // Try read more that file length.
        if (fLastModified == lastModified && fSz != 0 && pos >= fSz)
            throw new IOException("Trying to read file block with wrong offset: " + pos + " while file size: " + fSz);

        if (fSz == 0)
            return new VisorFileBlock(file.getPath(), pos, fLastModified, 0, false, EMPTY_FILE_BUF);
        else {
            int toRead = Math.min(blockSz, (int)(fSz - pos));

            raf = new RandomAccessFile(file, "r");
            raf.seek(pos);

            byte[] buf = new byte[toRead];

            int cntRead = raf.read(buf, 0, toRead);

            if (cntRead != toRead)
                throw new IOException("Count of requested and actually read bytes does not match [cntRead=" +
                    cntRead + ", toRead=" + toRead + ']');

            boolean zipped = buf.length > 512;

            return new VisorFileBlock(file.getPath(), pos, fSz, fLastModified, zipped, zipped ? zipBytes(buf) : buf);
        }
    }
    finally {
        U.close(raf, null);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:49,代码来源:VisorTaskUtils.java

示例12: cleanupConnections

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Called periodically by {@link GridTimeoutProcessor} to clean up the {@link #stmtCache}.
 */
private void cleanupConnections() {
    for (Iterator<Map.Entry<Thread, Connection>> it = conns.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<Thread, Connection> entry = it.next();

        Thread t = entry.getKey();

        if (t.getState() == Thread.State.TERMINATED) {
            U.close(entry.getValue(), log);

            it.remove();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:IgniteH2Indexing.java

示例13: cancelAllQueries

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void cancelAllQueries() {
    mapQryExec.cancelLazyWorkers();

    for (Connection c : conns.values())
        U.close(c, log);
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:IgniteH2Indexing.java

示例14: interrupt

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void interrupt() {
    super.interrupt();

    synchronized (this) {
        U.close(sock);

        sock = null;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:TcpDiscoveryMulticastIpFinder.java

示例15: checkStructure

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param garFile GAR file.
 * @param hasDescr Whether GAR file has descriptor.
 * @throws IOException If GAR file is not found.
 * @return Whether GAR file structure is correct.
 */
private boolean checkStructure(File garFile, boolean hasDescr) throws IOException {
    ZipFile zip = new ZipFile(garFile);

    String descr = "META-INF/ignite.xml";

    ZipEntry entry = zip.getEntry(descr);

    if (entry == null && !hasDescr) {
        if (log().isInfoEnabled()) {
            log().info("Process deployment without descriptor file [path=" +
                    descr + ", file=" + garFile.getAbsolutePath() + ']');
        }

        return true;
    }
    else if (entry != null && hasDescr) {
        InputStream in = null;

        try {
            in = new BufferedInputStream(zip.getInputStream(entry));

            return true;
        }
        finally {
            U.close(in, log());
        }
    }
    else
        return false;
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:GridToolsSelfTest.java


注:本文中的org.apache.ignite.internal.util.typedef.internal.U.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。