Search in sources :

Example 1 with Store

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);
    }
}
Also used : StreamStore(org.h2.mvstore.StreamStore) MVMap(org.h2.mvstore.MVMap)

Example 2 with Store

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);
    }
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) GridCursor(org.apache.ignite.internal.util.lang.GridCursor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) ArrayList(java.util.ArrayList) GridCursor(org.apache.ignite.internal.util.lang.GridCursor) Cursor(org.h2.index.Cursor)

Example 3 with Store

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)));
    }
}
Also used : MVStore(org.h2.mvstore.MVStore) KEY_HTTPS(com.adeptj.runtime.server.ServerConstants.KEY_HTTPS) RequestLimit(io.undertow.server.handlers.RequestLimit) SSLContext(javax.net.ssl.SSLContext) KEY_HTTP_ONLY(com.adeptj.runtime.server.ServerConstants.KEY_HTTP_ONLY) LogbackManagerHolder(com.adeptj.runtime.common.LogbackManagerHolder) StringUtils(org.apache.commons.lang3.StringUtils) HttpString(io.undertow.util.HttpString) KEY_LOGBACK_STATUS_SERVLET_PATH(com.adeptj.runtime.common.Constants.KEY_LOGBACK_STATUS_SERVLET_PATH) Environment(com.adeptj.runtime.common.Environment) GeneralSecurityException(java.security.GeneralSecurityException) REALM(com.adeptj.runtime.server.ServerConstants.REALM) KEY_ERROR_HANDLER_CODES(com.adeptj.runtime.common.Constants.KEY_ERROR_HANDLER_CODES) Path(java.nio.file.Path) ATTRIBUTE_BUNDLE_CONTEXT(com.adeptj.runtime.common.Constants.ATTRIBUTE_BUNDLE_CONTEXT) WORKER_TASK_CORE_THREADS(org.xnio.Options.WORKER_TASK_CORE_THREADS) MV_CREDENTIALS_STORE(com.adeptj.runtime.common.Constants.MV_CREDENTIALS_STORE) KEY_ERROR_HANDLER_PATH(com.adeptj.runtime.common.Constants.KEY_ERROR_HANDLER_PATH) AllowedMethodsHandler(io.undertow.server.handlers.AllowedMethodsHandler) Set(java.util.Set) KEY_WORKER_OPTIONS(com.adeptj.runtime.server.ServerConstants.KEY_WORKER_OPTIONS) LOGBACK_STATUS_SERVLET_NAME(com.adeptj.runtime.server.ServerConstants.LOGBACK_STATUS_SERVLET_NAME) KEY_PORT(com.adeptj.runtime.common.Constants.KEY_PORT) SYS_PROP_SERVER_HTTPS_PORT(com.adeptj.runtime.server.ServerConstants.SYS_PROP_SERVER_HTTPS_PORT) ContextPathPredicate(com.adeptj.runtime.predicate.ContextPathPredicate) KEY_HTTP(com.adeptj.runtime.common.Constants.KEY_HTTP) SYS_PROP_REQ_BUFF_MAX_BUFFERS(com.adeptj.runtime.server.ServerConstants.SYS_PROP_REQ_BUFF_MAX_BUFFERS) WORKER_TASK_MAX_THREADS(org.xnio.Options.WORKER_TASK_MAX_THREADS) KEY_HEALTH_CHECK_HANDLER_PATH(com.adeptj.runtime.server.ServerConstants.KEY_HEALTH_CHECK_HANDLER_PATH) KEY_WORKER_TASK_CORE_THREADS(com.adeptj.runtime.server.ServerConstants.KEY_WORKER_TASK_CORE_THREADS) ArrayList(java.util.ArrayList) RedirectHandler(io.undertow.server.handlers.RedirectHandler) Servlets(io.undertow.servlet.Servlets) KEY_AUTH_ROLES(com.adeptj.runtime.server.ServerConstants.KEY_AUTH_ROLES) MVStore(org.h2.mvstore.MVStore) ServletSessionConfig(io.undertow.servlet.api.ServletSessionConfig) SYS_PROP_SESSION_TIMEOUT(com.adeptj.runtime.server.ServerConstants.SYS_PROP_SESSION_TIMEOUT) KEY_INVALIDATE_SESSION_ON_LOGOUT(com.adeptj.runtime.server.ServerConstants.KEY_INVALIDATE_SESSION_ON_LOGOUT) KEY_MULTIPART_MAX_REQUEST_SIZE(com.adeptj.runtime.server.ServerConstants.KEY_MULTIPART_MAX_REQUEST_SIZE) KEY_WORKER_TASK_MAX_THREADS(com.adeptj.runtime.server.ServerConstants.KEY_WORKER_TASK_MAX_THREADS) WORKER_TASK_THREAD_MULTIPLIER(com.adeptj.runtime.server.ServerConstants.WORKER_TASK_THREAD_MULTIPLIER) Times(com.adeptj.runtime.common.Times) DEFAULT_WAIT_TIME(com.adeptj.runtime.server.ServerConstants.DEFAULT_WAIT_TIME) LinkedHashSet(java.util.LinkedHashSet) SYS_TASK_THREAD_MULTIPLIER(com.adeptj.runtime.server.ServerConstants.SYS_TASK_THREAD_MULTIPLIER) SYS_PROP_OVERWRITE_SERVER_CONF(com.adeptj.runtime.common.Constants.SYS_PROP_OVERWRITE_SERVER_CONF) KEY_MULTIPART_FILE_SIZE_THRESHOLD(com.adeptj.runtime.server.ServerConstants.KEY_MULTIPART_FILE_SIZE_THRESHOLD) Config(com.typesafe.config.Config) Files(java.nio.file.Files) SERVER_STRING(io.undertow.util.Headers.SERVER_STRING) SYS_PROP_MAX_CONCUR_REQ(com.adeptj.runtime.server.ServerConstants.SYS_PROP_MAX_CONCUR_REQ) KEY_HOST(com.adeptj.runtime.common.Constants.KEY_HOST) SYS_PROP_WORKER_TASK_THREAD_MULTIPLIER(com.adeptj.runtime.server.ServerConstants.SYS_PROP_WORKER_TASK_THREAD_MULTIPLIER) KEY_REQ_LIMIT_QUEUE_SIZE(com.adeptj.runtime.common.Constants.KEY_REQ_LIMIT_QUEUE_SIZE) IOException(java.io.IOException) KEY_SYSTEM_CONSOLE_PATH(com.adeptj.runtime.common.Constants.KEY_SYSTEM_CONSOLE_PATH) KEY_PROTECTED_PATHS_SECURED_FOR_METHODS(com.adeptj.runtime.server.ServerConstants.KEY_PROTECTED_PATHS_SECURED_FOR_METHODS) H2_MAP_ADMIN_CREDENTIALS(com.adeptj.runtime.common.Constants.H2_MAP_ADMIN_CREDENTIALS) Lifecycle(com.adeptj.runtime.common.Lifecycle) RequestLimitingHandler(io.undertow.server.handlers.RequestLimitingHandler) RequestBufferingHandler(io.undertow.server.handlers.RequestBufferingHandler) KEY_MULTIPART_MAX_FILE_SIZE(com.adeptj.runtime.server.ServerConstants.KEY_MULTIPART_MAX_FILE_SIZE) SYS_PROP_ENABLE_REQ_BUFF(com.adeptj.runtime.server.ServerConstants.SYS_PROP_ENABLE_REQ_BUFF) SYS_PROP_SHUTDOWN_WAIT_TIME(com.adeptj.runtime.server.ServerConstants.SYS_PROP_SHUTDOWN_WAIT_TIME) ServletContext(javax.servlet.ServletContext) GracefulShutdownHandler(io.undertow.server.handlers.GracefulShutdownHandler) KEY_DEFAULT_ENCODING(com.adeptj.runtime.server.ServerConstants.KEY_DEFAULT_ENCODING) HealthCheckHandler(com.adeptj.runtime.handler.HealthCheckHandler) DEPLOYMENT_NAME(com.adeptj.runtime.common.Constants.DEPLOYMENT_NAME) Handlers(io.undertow.Handlers) KEY_USE_CACHED_AUTH_MECHANISM(com.adeptj.runtime.server.ServerConstants.KEY_USE_CACHED_AUTH_MECHANISM) LoggerFactory(org.slf4j.LoggerFactory) SYS_PROP_SYS_TASK_THREAD_MULTIPLIER(com.adeptj.runtime.server.ServerConstants.SYS_PROP_SYS_TASK_THREAD_MULTIPLIER) RuntimeInitializer(com.adeptj.runtime.core.RuntimeInitializer) ServletInfo(io.undertow.servlet.api.ServletInfo) SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) Undertow(io.undertow.Undertow) KEY_ADMIN_SERVLET_PATH(com.adeptj.runtime.common.Constants.KEY_ADMIN_SERVLET_PATH) KEY_IGNORE_FLUSH(com.adeptj.runtime.server.ServerConstants.KEY_IGNORE_FLUSH) IOUtils(com.adeptj.runtime.common.IOUtils) KEY_HEADER_SERVER(com.adeptj.runtime.common.Constants.KEY_HEADER_SERVER) MVMap(org.h2.mvstore.MVMap) KEY_USER_CREDENTIAL_MAPPING(com.adeptj.runtime.server.ServerConstants.KEY_USER_CREDENTIAL_MAPPING) ErrorPage(io.undertow.servlet.api.ErrorPage) KEY_ALLOWED_METHODS(com.adeptj.runtime.common.Constants.KEY_ALLOWED_METHODS) KEY_MULTIPART_FILE_LOCATION(com.adeptj.runtime.server.ServerConstants.KEY_MULTIPART_FILE_LOCATION) KEY_REQ_BUFF_MAX_BUFFERS(com.adeptj.runtime.common.Constants.KEY_REQ_BUFF_MAX_BUFFERS) ADMIN_LOGIN_URI(com.adeptj.runtime.common.Constants.ADMIN_LOGIN_URI) Configs(com.adeptj.runtime.config.Configs) MultipartConfigElement(javax.servlet.MultipartConfigElement) Collectors(java.util.stream.Collectors) KEY_MAX_CONCURRENT_REQUESTS(com.adeptj.runtime.common.Constants.KEY_MAX_CONCURRENT_REQUESTS) BundleContextHolder(com.adeptj.runtime.common.BundleContextHolder) List(java.util.List) BANNER_TXT(com.adeptj.runtime.common.Constants.BANNER_TXT) KEY_CONTEXT_PATH(com.adeptj.runtime.server.ServerConstants.KEY_CONTEXT_PATH) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) ADMIN_SERVLET_NAME(com.adeptj.runtime.server.ServerConstants.ADMIN_SERVLET_NAME) CrawlerSessionManagerConfig(io.undertow.servlet.api.CrawlerSessionManagerConfig) FORM_AUTH(javax.servlet.http.HttpServletRequest.FORM_AUTH) ERROR_SERVLET_NAME(com.adeptj.runtime.server.ServerConstants.ERROR_SERVLET_NAME) SYS_PROP_REQ_LIMIT_QUEUE_SIZE(com.adeptj.runtime.server.ServerConstants.SYS_PROP_REQ_LIMIT_QUEUE_SIZE) PathHandler(io.undertow.server.handlers.PathHandler) ViewStatusMessagesServlet(ch.qos.logback.classic.ViewStatusMessagesServlet) SecurityConstraint(io.undertow.servlet.api.SecurityConstraint) PredicateHandler(io.undertow.server.handlers.PredicateHandler) KEY_PROTECTED_PATHS(com.adeptj.runtime.server.ServerConstants.KEY_PROTECTED_PATHS) SERVER_CONF_CP_RESOURCE(com.adeptj.runtime.common.Constants.SERVER_CONF_CP_RESOURCE) SYS_PROP_ENABLE_HTTP2(com.adeptj.runtime.server.ServerConstants.SYS_PROP_ENABLE_HTTP2) RuntimeInitializationException(com.adeptj.runtime.exception.RuntimeInitializationException) ServletInitialHandlerWrapper(com.adeptj.runtime.handler.ServletInitialHandlerWrapper) SYS_PROP_SERVER_PORT(com.adeptj.runtime.common.Constants.SYS_PROP_SERVER_PORT) KEY_SESSION_TIMEOUT(com.adeptj.runtime.server.ServerConstants.KEY_SESSION_TIMEOUT) Logger(org.slf4j.Logger) SslContextFactory(com.adeptj.runtime.common.SslContextFactory) AdminServlet(com.adeptj.runtime.servlet.AdminServlet) ErrorServlet(com.adeptj.runtime.servlet.ErrorServlet) DeploymentManager(io.undertow.servlet.api.DeploymentManager) HttpHandler(io.undertow.server.HttpHandler) FrameworkLauncher(com.adeptj.runtime.osgi.FrameworkLauncher) PWD_START_INDEX(com.adeptj.runtime.server.ServerConstants.PWD_START_INDEX) ServletContainerInitializerInfo(io.undertow.servlet.api.ServletContainerInitializerInfo) KEY_CHANGE_SESSION_ID_ON_LOGIN(com.adeptj.runtime.server.ServerConstants.KEY_CHANGE_SESSION_ID_ON_LOGIN) SetHeaderHandler(io.undertow.server.handlers.SetHeaderHandler) InputStream(java.io.InputStream) HttpString(io.undertow.util.HttpString)

Example 4 with Store

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);
    }
}
Also used : MVStore(org.h2.mvstore.MVStore) PasswordCredential(io.undertow.security.idm.PasswordCredential) ByteBuffer(java.nio.ByteBuffer)

Example 5 with Store

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);
        }
    }
}
Also used : FileStoreInputStream(org.h2.store.FileStoreInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileStoreInputStream(org.h2.store.FileStoreInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

MVStore (org.h2.mvstore.MVStore)72 IOException (java.io.IOException)34 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)27 ByteArrayInputStream (java.io.ByteArrayInputStream)19 HashMap (java.util.HashMap)17 InputStream (java.io.InputStream)16 ArrayList (java.util.ArrayList)16 Random (java.util.Random)14 DbException (org.h2.message.DbException)14 StreamStore (org.h2.mvstore.StreamStore)14 Store (org.h2.mvstore.db.Store)14 TransactionStore (org.h2.mvstore.tx.TransactionStore)14 Row (org.h2.result.Row)14 Map (java.util.Map)13 FileStore (org.h2.mvstore.FileStore)12 OutputStream (java.io.OutputStream)11 FileStore (org.h2.store.FileStore)11 File (java.io.File)10 Constraint (org.h2.constraint.Constraint)10 FileStoreInputStream (org.h2.store.FileStoreInputStream)10