本文整理汇总了Java中com.ceph.rados.jna.RadosObjectInfo类的典型用法代码示例。如果您正苦于以下问题:Java RadosObjectInfo类的具体用法?Java RadosObjectInfo怎么用?Java RadosObjectInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RadosObjectInfo类属于com.ceph.rados.jna包,在下文中一共展示了RadosObjectInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exists
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
@Override
public boolean exists() {
IoCTX ioctx = null;
try {
ioctx = this.rados.ioCtxCreate(pool);
RadosObjectInfo stat = ioctx.stat(locator);
return stat != null;
} catch (RadosException e) {
logger.error(e.getMessage(), e);
} finally {
if (ioctx != null) {
this.rados.ioCtxDestroy(ioctx);
}
}
return false;
}
示例2: getLastModified
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
@Override
public long getLastModified() {
IoCTX ioctx = null;
try {
ioctx = this.rados.ioCtxCreate(this.pool);
RadosObjectInfo stat = ioctx.stat(this.locator);
if (stat != null) {
return stat.getMtime();
}
} catch (RadosException e) {
logger.error(e.getMessage(), e);
} finally {
if (ioctx != null) {
this.rados.ioCtxDestroy(ioctx);
}
}
return 0L;
}
示例3: getSize
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
@Override
public long getSize() {
IoCTX ioctx = null;
try {
ioctx = this.rados.ioCtxCreate(this.pool);
RadosObjectInfo stat = ioctx.stat(this.locator);
if (stat != null) {
return stat.getSize();
}
} catch (RadosException e) {
logger.error(e.getMessage(), e);
} finally {
if (ioctx != null) {
this.rados.ioCtxDestroy(ioctx);
}
}
return 0L;
}
示例4: inodeExists
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
public boolean inodeExists(Path path) throws IOException {
String key = pathToKey(path);
try {
RadosObjectInfo info = get(key);
if (info == null) {
if (isRoot(key)) {
storeINode(path, INode.DIRECTORY_INODE);
return true;
} else {
return false;
}
}
} catch (Exception e) {
throw new IOException("store inode failed");
}
return true;
}
示例5: blockExists
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
public boolean blockExists(long blockId) throws IOException {
try {
RadosObjectInfo info = get(blockToKey(blockId));
if (info == null) {
return false;
}
} catch (Exception e) {
throw new IOException("block get failed");
}
return true;
}
示例6: get
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
private RadosObjectInfo get(String key)
throws Exception {
RadosObjectInfo info = null;
try {
info = ioctx.stat(key);
return info;
} catch (Exception e) {
return null;
}
}
示例7: retrieveINode
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
public INode retrieveINode(Path path) throws IOException {
String key = pathToKey(path);
try {
RadosObjectInfo info = get(key);
if (info == null && isRoot(key)) {
storeINode(path, INode.DIRECTORY_INODE);
return INode.DIRECTORY_INODE;
}
return INode.deserialize(new RadosInputStream(ioctx, info.getOid()));
} catch (Exception e) {
throw new IOException("get inode failed");
}
}
示例8: retrieveBlock
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
public byte[] retrieveBlock(Block block, long byteRangeStart)
throws IOException {
RadosObjectInfo info = null;
InputStream in = null;
OutputStream out = null;
try {
info = get(blockToKey(block), byteRangeStart);
if (null == info) {
throw new IOException("no such object");
}
in = new RadosInputStream(ioctx, info.getOid());
out = new RadosOutputStream(ioctx, info.getOid());
int bufferSize = in.available() - (int)byteRangeStart;
byte[] buf = new byte[bufferSize];
int numRead;
while ((numRead = in.read(buf)) > 0) {
out.write(buf, 0, numRead);
}
return buf;
} catch (IOException e) {
// close output stream to file then delete file
closeQuietly(out);
out = null; // to prevent a second close
throw e;
} finally {
closeQuietly(out);
closeQuietly(in);
}
}
示例9: stat
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
/**
* Stat an object
*
* @param oid
* The name of the object
* @return RadosObjectInfo
* The size and mtime of the object
* @throws RadosException
*/
public RadosObjectInfo stat(final String oid) throws RadosException {
final LongByReference size = new LongByReference();
final LongByReference mtime = new LongByReference();
handleReturnCode(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return rados.rados_stat(getPointer(), oid, size, mtime);
}
}, "Failed performing a stat on object %s", oid);
return new RadosObjectInfo(oid, size.getValue(), mtime.getValue());
}
示例10: verifyDocument
import com.ceph.rados.jna.RadosObjectInfo; //导入依赖的package包/类
private void verifyDocument(String oid, byte[] content) throws RadosException {
byte[] buf = new byte[content.length];
int len = ioctx.read(oid, content.length, 0, buf);
assertEquals(len, content.length);
RadosObjectInfo info = ioctx.stat(oid);
assertEquals("The object names didn't match", oid, info.getOid());
assertEquals("The size of what we wrote doesn't match with the stat", content.length, info.getSize());
assertTrue("The content we read was different from what we wrote", Arrays.equals(content, buf));
long now = System.currentTimeMillis() / 1000;
assertFalse("The mtime was in the future", now < info.getMtime());
}