use of org.h2.mvstore.db.Store in project jackrabbit-oak by apache.
the class BlobCache method addGeneration.
@Override
public void addGeneration(int generation, boolean readOnly) {
CacheMap<Long, byte[]> d = cache.openMap(generation, "data", new MVMap.Builder<Long, byte[]>());
data.addReadMap(generation, d);
CacheMap<String, byte[]> m = cache.openMap(generation, "meta", new MVMap.Builder<String, byte[]>());
meta.addReadMap(generation, m);
if (!readOnly) {
// the order is important:
// if we switch the data first,
// we could end up with the data in store 1
// but the metadata in store 2 - which could
// result in a data block not found if store 1
// is removed later on
meta.setWriteMap(m);
data.setWriteMap(d);
}
if (streamStore == null) {
streamStore = new StreamStore(data);
}
}
use of org.h2.mvstore.db.Store in project ignite by apache.
the class H2PkHashIndex method totalRowCount.
/**
* {@inheritDoc}
*/
@Override
public long totalRowCount(IndexingQueryCacheFilter partsFilter) {
CacheDataRowStore.setSkipVersion(true);
try {
Collection<GridCursor<? extends CacheDataRow>> cursors = new ArrayList<>();
for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores()) {
int part = store.partId();
if (partsFilter == null || partsFilter.applyPartition(part))
cursors.add(store.cursor(cctx.cacheId()));
}
Cursor pkHashCursor = new H2PkHashIndexCursor(cursors.iterator());
long res = 0;
while (pkHashCursor.next()) res++;
return res;
} catch (IgniteCheckedException e) {
throw U.convertException(e);
} finally {
CacheDataRowStore.setSkipVersion(false);
}
}
use of org.h2.mvstore.db.Store in project adeptj-runtime by AdeptJ.
the class Server method populateCredentialsStore.
private void populateCredentialsStore(Config undertowConf) {
try (MVStore store = MVStore.open(MV_CREDENTIALS_STORE)) {
MVMap<String, String> credentials = store.openMap(H2_MAP_ADMIN_CREDENTIALS);
// put the default password only when it is not set from web console.
undertowConf.getObject(KEY_USER_CREDENTIAL_MAPPING).entrySet().stream().filter(entry -> StringUtils.isEmpty(credentials.get(entry.getKey()))).forEach(entry -> credentials.put(entry.getKey(), ((String) entry.getValue().unwrapped()).substring(PWD_START_INDEX)));
}
}
use of org.h2.mvstore.db.Store in project adeptj-runtime by AdeptJ.
the class CredentialMatcher method match.
static boolean match(String username, Credential credential) {
char[] inputPwd = ((PasswordCredential) credential).getPassword();
if (StringUtils.isEmpty(username) || ArrayUtils.isEmpty(inputPwd)) {
return false;
}
byte[] inputPwdBytes = null;
byte[] digest = null;
byte[] storedPwdBytes = null;
try (MVStore store = MVStore.open(MV_CREDENTIALS_STORE)) {
String storedPwd = (String) store.openMap(H2_MAP_ADMIN_CREDENTIALS).get(username);
if (StringUtils.isEmpty(storedPwd)) {
return false;
}
ByteBuffer buffer = UTF_8.encode(CharBuffer.wrap(inputPwd));
inputPwdBytes = new byte[buffer.limit()];
buffer.get(inputPwdBytes);
digest = Base64.getEncoder().encode(sha256(inputPwdBytes));
storedPwdBytes = storedPwd.getBytes(UTF_8);
return MessageDigest.isEqual(digest, storedPwdBytes);
} finally {
nullSafeWipe(inputPwdBytes, digest, storedPwdBytes);
}
}
use of org.h2.mvstore.db.Store in project h2database by h2database.
the class ScriptBase method openInput.
/**
* Open the input stream.
*/
void openInput() {
String file = getFileName();
if (file == null) {
return;
}
if (isEncrypted()) {
initStore();
in = new FileStoreInputStream(store, this, compressionAlgorithm != null, false);
} else {
InputStream inStream;
try {
inStream = FileUtils.newInputStream(file);
} catch (IOException e) {
throw DbException.convertIOException(e, file);
}
in = new BufferedInputStream(inStream, Constants.IO_BUFFER_SIZE);
in = CompressTool.wrapInputStream(in, compressionAlgorithm, SCRIPT_SQL);
if (in == null) {
throw DbException.get(ErrorCode.FILE_NOT_FOUND_1, SCRIPT_SQL + " in " + file);
}
}
}
Aggregations