All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micronaut.crac.resources.datasources.UnknownDataSourceResource Maven / Gradle / Ivy

Go to download

Adds support for CRaC (Coordinated Restore at Checkpoint) to the Micronaut Framework.

The newest version!
/*
 * Copyright 2017-2022 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.crac.resources.datasources;

import io.micronaut.core.annotation.Experimental;
import org.crac.Context;
import org.crac.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;

/**
 * Handler for currently unhandled DataSources.
 *
 * @author Tim Yates
 * @since 1.1.0
 */
@Experimental
public class UnknownDataSourceResource implements Resource {

    private static final Logger LOG = LoggerFactory.getLogger(UnknownDataSourceResource.class);

    private final DataSource dataSource;

    public UnknownDataSourceResource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public void beforeCheckpoint(Context context) throws Exception {
        if (LOG.isWarnEnabled()) {
            LOG.warn("Cannot suspend DataSource {}", dataSource.getClass().getName());
        }
    }

    @Override
    public void afterRestore(Context context) throws Exception {
        if (LOG.isWarnEnabled()) {
            LOG.warn("Cannot resume DataSource {}", dataSource.getClass().getName());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy