Search in sources :

Example 1 with Offloaders

use of org.apache.bookkeeper.mledger.offload.Offloaders in project pulsar by apache.

the class PulsarService method createManagedLedgerOffloader.

public synchronized LedgerOffloader createManagedLedgerOffloader(OffloadPoliciesImpl offloadPolicies) throws PulsarServerException {
    try {
        if (StringUtils.isNotBlank(offloadPolicies.getManagedLedgerOffloadDriver())) {
            checkNotNull(offloadPolicies.getOffloadersDirectory(), "Offloader driver is configured to be '%s' but no offloaders directory is configured.", offloadPolicies.getManagedLedgerOffloadDriver());
            Offloaders offloaders = offloadersCache.getOrLoadOffloaders(offloadPolicies.getOffloadersDirectory(), config.getNarExtractionDirectory());
            LedgerOffloaderFactory offloaderFactory = offloaders.getOffloaderFactory(offloadPolicies.getManagedLedgerOffloadDriver());
            try {
                return offloaderFactory.create(offloadPolicies, ImmutableMap.of(LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(), LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha()), schemaStorage, getOffloaderScheduler(offloadPolicies));
            } catch (IOException ioe) {
                throw new PulsarServerException(ioe.getMessage(), ioe.getCause());
            }
        } else {
            LOG.info("No ledger offloader configured, using NULL instance");
            return NullLedgerOffloader.INSTANCE;
        }
    } catch (Throwable t) {
        throw new PulsarServerException(t);
    }
}
Also used : LedgerOffloaderFactory(org.apache.bookkeeper.mledger.LedgerOffloaderFactory) Offloaders(org.apache.bookkeeper.mledger.offload.Offloaders) IOException(java.io.IOException)

Example 2 with Offloaders

use of org.apache.bookkeeper.mledger.offload.Offloaders in project pulsar by apache.

the class PulsarConnectorCache method initManagedLedgerOffloader.

private LedgerOffloader initManagedLedgerOffloader(OffloadPoliciesImpl offloadPolicies, PulsarConnectorConfig pulsarConnectorConfig) {
    try {
        if (StringUtils.isNotBlank(offloadPolicies.getManagedLedgerOffloadDriver())) {
            checkNotNull(offloadPolicies.getOffloadersDirectory(), "Offloader driver is configured to be '%s' but no offloaders directory is configured.", offloadPolicies.getManagedLedgerOffloadDriver());
            Offloaders offloaders = offloadersCache.getOrLoadOffloaders(offloadPolicies.getOffloadersDirectory(), pulsarConnectorConfig.getNarExtractionDirectory());
            LedgerOffloaderFactory offloaderFactory = offloaders.getOffloaderFactory(offloadPolicies.getManagedLedgerOffloadDriver());
            try {
                return offloaderFactory.create(offloadPolicies, ImmutableMap.of(LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(), LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha()), getOffloaderScheduler(offloadPolicies));
            } catch (IOException ioe) {
                log.error("Failed to create offloader: ", ioe);
                throw new RuntimeException(ioe.getMessage(), ioe.getCause());
            }
        } else {
            log.info("No ledger offloader configured, using NULL instance");
            return NullLedgerOffloader.INSTANCE;
        }
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}
Also used : LedgerOffloaderFactory(org.apache.bookkeeper.mledger.LedgerOffloaderFactory) Offloaders(org.apache.bookkeeper.mledger.offload.Offloaders) IOException(java.io.IOException)

Example 3 with Offloaders

use of org.apache.bookkeeper.mledger.offload.Offloaders in project pulsar by yahoo.

the class PulsarService method createManagedLedgerOffloader.

public synchronized LedgerOffloader createManagedLedgerOffloader(OffloadPoliciesImpl offloadPolicies) throws PulsarServerException {
    try {
        if (StringUtils.isNotBlank(offloadPolicies.getManagedLedgerOffloadDriver())) {
            checkNotNull(offloadPolicies.getOffloadersDirectory(), "Offloader driver is configured to be '%s' but no offloaders directory is configured.", offloadPolicies.getManagedLedgerOffloadDriver());
            Offloaders offloaders = offloadersCache.getOrLoadOffloaders(offloadPolicies.getOffloadersDirectory(), config.getNarExtractionDirectory());
            LedgerOffloaderFactory offloaderFactory = offloaders.getOffloaderFactory(offloadPolicies.getManagedLedgerOffloadDriver());
            try {
                return offloaderFactory.create(offloadPolicies, ImmutableMap.of(LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(), LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha(), LedgerOffloader.METADATA_PULSAR_CLUSTER_NAME.toLowerCase(), config.getClusterName()), schemaStorage, getOffloaderScheduler(offloadPolicies), this.offloaderStats);
            } catch (IOException ioe) {
                throw new PulsarServerException(ioe.getMessage(), ioe.getCause());
            }
        } else {
            LOG.info("No ledger offloader configured, using NULL instance");
            return NullLedgerOffloader.INSTANCE;
        }
    } catch (Throwable t) {
        throw new PulsarServerException(t);
    }
}
Also used : LedgerOffloaderFactory(org.apache.bookkeeper.mledger.LedgerOffloaderFactory) Offloaders(org.apache.bookkeeper.mledger.offload.Offloaders) IOException(java.io.IOException)

Example 4 with Offloaders

use of org.apache.bookkeeper.mledger.offload.Offloaders in project pulsar by yahoo.

the class PulsarConnectorCache method initManagedLedgerOffloader.

private LedgerOffloader initManagedLedgerOffloader(OffloadPoliciesImpl offloadPolicies, PulsarConnectorConfig pulsarConnectorConfig) {
    try {
        if (StringUtils.isNotBlank(offloadPolicies.getManagedLedgerOffloadDriver())) {
            checkNotNull(offloadPolicies.getOffloadersDirectory(), "Offloader driver is configured to be '%s' but no offloaders directory is configured.", offloadPolicies.getManagedLedgerOffloadDriver());
            Offloaders offloaders = offloadersCache.getOrLoadOffloaders(offloadPolicies.getOffloadersDirectory(), pulsarConnectorConfig.getNarExtractionDirectory());
            LedgerOffloaderFactory offloaderFactory = offloaders.getOffloaderFactory(offloadPolicies.getManagedLedgerOffloadDriver());
            try {
                return offloaderFactory.create(offloadPolicies, ImmutableMap.of(LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(), LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha()), this.offloaderScheduler, this.offloaderStats);
            } catch (IOException ioe) {
                log.error("Failed to create offloader: ", ioe);
                throw new RuntimeException(ioe.getMessage(), ioe.getCause());
            }
        } else {
            log.info("No ledger offloader configured, using NULL instance");
            return NullLedgerOffloader.INSTANCE;
        }
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}
Also used : LedgerOffloaderFactory(org.apache.bookkeeper.mledger.LedgerOffloaderFactory) Offloaders(org.apache.bookkeeper.mledger.offload.Offloaders) IOException(java.io.IOException)

Example 5 with Offloaders

use of org.apache.bookkeeper.mledger.offload.Offloaders in project incubator-pulsar by apache.

the class PulsarService method createManagedLedgerOffloader.

public synchronized LedgerOffloader createManagedLedgerOffloader(OffloadPoliciesImpl offloadPolicies) throws PulsarServerException {
    try {
        if (StringUtils.isNotBlank(offloadPolicies.getManagedLedgerOffloadDriver())) {
            checkNotNull(offloadPolicies.getOffloadersDirectory(), "Offloader driver is configured to be '%s' but no offloaders directory is configured.", offloadPolicies.getManagedLedgerOffloadDriver());
            Offloaders offloaders = offloadersCache.getOrLoadOffloaders(offloadPolicies.getOffloadersDirectory(), config.getNarExtractionDirectory());
            LedgerOffloaderFactory offloaderFactory = offloaders.getOffloaderFactory(offloadPolicies.getManagedLedgerOffloadDriver());
            try {
                return offloaderFactory.create(offloadPolicies, ImmutableMap.of(LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(), LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha(), LedgerOffloader.METADATA_PULSAR_CLUSTER_NAME.toLowerCase(), config.getClusterName()), schemaStorage, getOffloaderScheduler(offloadPolicies), this.offloaderStats);
            } catch (IOException ioe) {
                throw new PulsarServerException(ioe.getMessage(), ioe.getCause());
            }
        } else {
            LOG.info("No ledger offloader configured, using NULL instance");
            return NullLedgerOffloader.INSTANCE;
        }
    } catch (Throwable t) {
        throw new PulsarServerException(t);
    }
}
Also used : LedgerOffloaderFactory(org.apache.bookkeeper.mledger.LedgerOffloaderFactory) Offloaders(org.apache.bookkeeper.mledger.offload.Offloaders) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)6 LedgerOffloaderFactory (org.apache.bookkeeper.mledger.LedgerOffloaderFactory)6 Offloaders (org.apache.bookkeeper.mledger.offload.Offloaders)6