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


Java SqlJetDb.runReadTransaction方法代码示例

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


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

示例1: size

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public long size() {
	try {
		ISqlJetTransaction getCountTx=new ISqlJetTransaction() {
			@Override
			public Object run(SqlJetDb db) throws SqlJetException {
				ISqlJetCursor allRowsCursor = nodeInfoTable.scope(null, null, null);
				long count=allRowsCursor.getRowCount();
				allRowsCursor.close();
				return count;
			}
		};
		return (long) db.runReadTransaction(getCountTx);
	} catch (SqlJetException e) {
		LOGGER.error("Db error", e);
		throw new RuntimeException(e);
	}
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:18,代码来源:NodeStatisticsDatabase.java

示例2: getEndpointByNodeIdentifier

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public InetSocketAddress getEndpointByNodeIdentifier(final NodeIdentifier remoteID) {
	try {
		ISqlJetTransaction getEndpointTx=new ISqlJetTransaction() {
			@Override public Object run(SqlJetDb db) throws SqlJetException {
				ISqlJetCursor nodeInfoCursor = nodeInfoTable.lookup(null, remoteID.getBytes());
				InetSocketAddress endpoint=null;
				if(nodeInfoCursor.eof()==false){
					endpoint=new InetSocketAddress(nodeInfoCursor.getString(ENDPOINT_ADDRESS_FN), 
							(int) nodeInfoCursor.getInteger(ENDPOINT_PORT_FN));
				}
				nodeInfoCursor.close();
				return endpoint;
			}
		};
		return (InetSocketAddress) db.runReadTransaction(getEndpointTx);
	} catch (SqlJetException e) {
		LOGGER.error("db error", e);
		throw new RuntimeException(e);
	}
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:21,代码来源:NodeStatisticsDatabase.java

示例3: getAllNodeInformation

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<NodeMetaData> getAllNodeInformation(final int maxNumberOfNodes){
	ISqlJetTransaction getAllNodesTx=new ISqlJetTransaction() {
		@Override public Object run(SqlJetDb db) throws SqlJetException {
			ArrayList<NodeMetaData> listOfNodeInfo=new ArrayList<>();
			ISqlJetCursor allNodesCursor = nodeInfoTable.scope(nodeInfoTable.getPrimaryKeyIndexName(), null, null);
			for(int i=0; i<maxNumberOfNodes && allNodesCursor.eof()==false; i++){
				InetSocketAddress endPoint=new InetSocketAddress(allNodesCursor.getString(ENDPOINT_ADDRESS_FN), 
						(int) allNodesCursor.getInteger(ENDPOINT_PORT_FN));
				
				NodeIdentifier nodeId=new NodeIdentifier(allNodesCursor.getBlobAsArray(NODE_ID_FN));
				NodeMetaData currentBNI=new NodeMetaData(nodeId, endPoint);
				listOfNodeInfo.add(currentBNI);
				
				allNodesCursor.next();
			}
			allNodesCursor.close();
			return listOfNodeInfo;
		}
	};
	try {
		return (List<NodeMetaData>) db.runReadTransaction(getAllNodesTx);
	} catch (SqlJetException e) {
		LOGGER.error("DB error", e);
		throw new RuntimeException(e);
	}
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:28,代码来源:NodeStatisticsDatabase.java

示例4: getStoredBlob

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
@Override
public P2PBlobStoredBlob getStoredBlob(final HashIdentifier blobId) throws Exception{
	synchronized(cachedTransitStatus){
		P2PBlobStoredBlobRepositoryFS transitStatus = cachedTransitStatus.get(blobId);
		if(transitStatus!=null){
			return transitStatus;
		}

		ISqlJetTransaction getStoredBlockTx=new ISqlJetTransaction() {
			@Override public Object run(SqlJetDb db) throws SqlJetException {
				ISqlJetCursor blobMetaCursor = blobMetaTable.lookup(BLOB_META_BLOBHASH_IDX, blobId.getBytes());
				if(blobMetaCursor.eof()){
					return null;
				}
				long blobByteSize=blobMetaCursor.getInteger("blobByteSize");
         int blockByteSize=(int) blobMetaCursor.getInteger("blockByteSize");
				String localBlockRangeStr=blobMetaCursor.getString("rangeLocalBlock");
				P2PBlobRangeSet localBlockRange=null;
				if(localBlockRangeStr!=null){
					localBlockRange=new P2PBlobRangeSet(localBlockRangeStr);
				}
				P2PBlobHashList hashList=new P2PBlobHashList(blobMetaCursor.getBlobAsArray("blocksHash"));
				File blobFile = getBlobFile(blobId);
         P2PBlobStoredBlobRepositoryFS status=new P2PBlobStoredBlobRepositoryFS(blobFile,blobId, hashList, localBlockRange, blobByteSize, blockByteSize);
				cachedTransitStatus.put(blobId, status);
				return status;
			}
		};

		try {
			return (P2PBlobStoredBlob) db.runReadTransaction(getStoredBlockTx);
		} catch (SqlJetException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:38,代码来源:P2PBlobRepositoryFS.java

示例5: getBalanceForNode

import org.tmatesoft.sqljet.core.table.SqlJetDb; //导入方法依赖的package包/类
public long getBalanceForNode(final NodeIdentifier nodeId) throws SqlJetException {
	ISqlJetTransaction getBalanceTx=new ISqlJetTransaction() {
		@Override public Object run(SqlJetDb db) throws SqlJetException {
			ISqlJetCursor nodeAccountCursor = balanceTable.lookup(null, nodeId.getBytes());
			long balance=0;
			if(nodeAccountCursor.eof()==false){
				balance=nodeAccountCursor.getInteger(BALANCE_FN);
			}
			nodeAccountCursor.close();
			return balance;
		}
	};
	return (long) db.runReadTransaction(getBalanceTx);
}
 
开发者ID:pmarches,项目名称:peercentrum-core,代码行数:15,代码来源:AbstractNodeBalanceTable.java


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