Search in sources :

Example 1 with InvalidServiceNameException

use of org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException in project teiid by teiid.

the class EngineStatistics method updateServices.

static void updateServices(OperationContext context, RuntimeVDB vdb, String dsName, ReplaceResult rr) {
    if (rr.isNew) {
        VDBDeployer.addDataSourceListener(context.getServiceTarget(), new VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName);
    }
    if (rr.removedDs != null) {
        final ServiceRegistry registry = context.getServiceRegistry(true);
        ServiceName serviceName;
        try {
            serviceName = TeiidServiceNames.dsListenerServiceName(vdb.getVdb().getName(), vdb.getVdb().getVersion(), rr.removedDs);
        } catch (InvalidServiceNameException e) {
            // the old isn't valid
            return;
        }
        final ServiceController<?> controller = registry.getService(serviceName);
        if (controller != null) {
            context.removeService(serviceName);
        }
    }
}
Also used : VDBKey(org.teiid.vdb.runtime.VDBKey) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) InvalidServiceNameException(org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException)

Example 2 with InvalidServiceNameException

use of org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException in project teiid by teiid.

the class VDBDeployer method undeploy.

@Override
public void undeploy(final DeploymentUnit deploymentUnit) {
    if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
        return;
    }
    final VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
    if (!this.shutdownListener.isShutdownInProgress()) {
        final VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
        ServiceController<?> sc = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.OBJECT_SERIALIZER);
        if (sc != null) {
            ObjectSerializer serilalizer = ObjectSerializer.class.cast(sc.getValue());
            serilalizer.removeAttachments(vdb);
            // $NON-NLS-1$ //$NON-NLS-2$
            LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB " + vdb.getName() + " metadata removed");
        }
    }
    this.vdbRepository.removeVDB(deployment.getName(), deployment.getVersion());
    ServiceController<?> switchSvc = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.vdbSwitchServiceName(deployment.getName(), deployment.getVersion()));
    if (switchSvc != null) {
        switchSvc.setMode(ServiceController.Mode.REMOVE);
    }
    for (ModelMetaData model : deployment.getModelMetaDatas().values()) {
        for (SourceMappingMetadata smm : model.getSources().values()) {
            String dsName = smm.getConnectionJndiName();
            if (dsName == null) {
                continue;
            }
            ServiceController<?> dsService;
            try {
                dsService = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.dsListenerServiceName(deployment.getName(), deployment.getVersion(), dsName));
            } catch (InvalidServiceNameException e) {
                continue;
            }
            if (dsService != null) {
                dsService.setMode(ServiceController.Mode.REMOVE);
            }
        }
    }
    final ServiceController<?> controller = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.vdbServiceName(deployment.getName(), deployment.getVersion()));
    if (controller != null) {
        controller.setMode(ServiceController.Mode.REMOVE);
    }
}
Also used : SourceMappingMetadata(org.teiid.adminapi.impl.SourceMappingMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) InvalidServiceNameException(org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

InvalidServiceNameException (org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException)2 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)1 SourceMappingMetadata (org.teiid.adminapi.impl.SourceMappingMetadata)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 VDBKey (org.teiid.vdb.runtime.VDBKey)1