use of co.cask.cdap.api.TxRunnable in project cdap by caskdata.
the class DefaultStore method removeAllApplications.
@Override
public void removeAllApplications(final NamespaceId id) {
LOG.trace("Removing all applications of namespace with id: {}", id.getNamespace());
Transactions.executeUnchecked(transactional, new TxRunnable() {
@Override
public void run(DatasetContext context) throws Exception {
AppMetadataStore metaStore = getAppMetadataStore(context);
metaStore.deleteApplications(id.getNamespace());
metaStore.deleteProgramHistory(id.getNamespace());
}
});
}
use of co.cask.cdap.api.TxRunnable in project cdap by caskdata.
the class DefaultStore method removeAll.
@Override
public void removeAll(final NamespaceId id) {
LOG.trace("Removing all applications of namespace with id: {}", id.getNamespace());
Transactions.executeUnchecked(transactional, new TxRunnable() {
@Override
public void run(DatasetContext context) throws Exception {
AppMetadataStore metaStore = getAppMetadataStore(context);
metaStore.deleteApplications(id.getNamespace());
metaStore.deleteAllStreams(id.getNamespace());
metaStore.deleteProgramHistory(id.getNamespace());
}
});
}
use of co.cask.cdap.api.TxRunnable in project cdap by caskdata.
the class DefaultStore method setServiceInstances.
@Override
public void setServiceInstances(final ProgramId id, final int instances) {
Preconditions.checkArgument(instances > 0, "Cannot change number of service instances to %s", instances);
Transactions.executeUnchecked(transactional, new TxRunnable() {
@Override
public void run(DatasetContext context) throws Exception {
AppMetadataStore metaStore = getAppMetadataStore(context);
ApplicationSpecification appSpec = getAppSpecOrFail(metaStore, id);
ServiceSpecification serviceSpec = getServiceSpecOrFail(id, appSpec);
// Create a new spec copy from the old one, except with updated instances number
serviceSpec = new ServiceSpecification(serviceSpec.getClassName(), serviceSpec.getName(), serviceSpec.getDescription(), serviceSpec.getHandlers(), serviceSpec.getResources(), instances);
ApplicationSpecification newAppSpec = replaceServiceSpec(appSpec, id.getProgram(), serviceSpec);
metaStore.updateAppSpec(id.getNamespace(), id.getApplication(), id.getVersion(), newAppSpec);
}
});
LOG.trace("Setting program instances: namespace: {}, application: {}, service: {}, new instances count: {}", id.getNamespaceId(), id.getApplication(), id.getProgram(), instances);
}
use of co.cask.cdap.api.TxRunnable in project cdap by caskdata.
the class DefaultStore method removeApplication.
@Override
public void removeApplication(final ApplicationId id) {
LOG.trace("Removing application: namespace: {}, application: {}", id.getNamespace(), id.getApplication());
Transactions.executeUnchecked(transactional, new TxRunnable() {
@Override
public void run(DatasetContext context) throws Exception {
AppMetadataStore metaStore = getAppMetadataStore(context);
metaStore.deleteApplication(id.getNamespace(), id.getApplication(), id.getVersion());
metaStore.deleteProgramHistory(id.getNamespace(), id.getApplication(), id.getVersion());
}
});
}
use of co.cask.cdap.api.TxRunnable in project cdap by caskdata.
the class DefaultStore method setWorkerInstances.
@Override
public void setWorkerInstances(final ProgramId id, final int instances) {
Preconditions.checkArgument(instances > 0, "Cannot change number of worker instances to %s", instances);
Transactions.executeUnchecked(transactional, new TxRunnable() {
@Override
public void run(DatasetContext context) throws Exception {
AppMetadataStore metaStore = getAppMetadataStore(context);
ApplicationSpecification appSpec = getAppSpecOrFail(metaStore, id);
WorkerSpecification workerSpec = getWorkerSpecOrFail(id, appSpec);
WorkerSpecification newSpecification = new WorkerSpecification(workerSpec.getClassName(), workerSpec.getName(), workerSpec.getDescription(), workerSpec.getProperties(), workerSpec.getDatasets(), workerSpec.getResources(), instances);
ApplicationSpecification newAppSpec = replaceWorkerInAppSpec(appSpec, id, newSpecification);
metaStore.updateAppSpec(id.getNamespace(), id.getApplication(), id.getVersion(), newAppSpec);
}
});
LOG.trace("Setting program instances: namespace: {}, application: {}, worker: {}, new instances count: {}", id.getNamespaceId(), id.getApplication(), id.getProgram(), instances);
}
Aggregations