Refine search
public static ConfigBeanProxy deepCopy(ConfigBeanProxy self, ConfigBeanProxy parent) throws TransactionFailure { ConfigBean configBean = (ConfigBean) Dom.unwrap(self); // ensure the parent is locked Transaction t = Transaction.getTransaction(parent); if (t==null) { throw new TransactionFailure("Must use a locked parent config object for copying new config object"); } ConfigBean copy = configBean.copy(configBean.parent()); return t.enroll(copy.createProxy()); }
Transaction t = new Transaction(); for (WriteableView view : views) { if (!view.join(t)) { t.rollback(); throw new TransactionFailure("Cannot enlist " + view.getMasterView().getProxyType() + " in transaction", null); final Object toReturn = code.run(proxies); try { t.commit(); if (toReturn instanceof WriteableView) { return ((WriteableView) toReturn).getMasterView(); t.rollback(); return null; } catch (TransactionFailure e) { t.rollback(); throw e; t.rollback(); Throwable throwable = e.getCause(); if (throwable instanceof PropertyVetoException) throw new TransactionFailure(throwable.toString(), throwable); throw new TransactionFailure(e.toString(), e); t.rollback(); throw e; } catch (Exception e) { t.rollback(); throw new TransactionFailure(e.getMessage(), e);
/** * Enter a new Transaction, this method should return false if this object * is already enlisted in another transaction, or cannot be enlisted with * the passed transaction. If the object returns true, the object * is enlisted in the passed transaction and cannot be enlisted in another * transaction until either commit or abort has been issued. * * @param t the transaction to enlist with * @return true if the enlisting with the passed transaction was accepted, * false otherwise */ public synchronized boolean join(Transaction t) { if (currentTx==null) { currentTx = t; t.addParticipant(this); return true; } return false; }
private static void commit(final Transaction t) throws TransactionFailure { try { t.commit(); } catch (final RetryableException e) { t.rollback(); throw new TransactionFailure(e.getMessage(), e); } catch (final TransactionFailure e) { //cdebug("failure, not retryable..."); t.rollback(); throw e; } }
Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Server.class); Transaction tx = Transaction.getTransaction(instance); String configRef = instance.getConfigRef(); Clusters clusters = domain.getClusters(); throw new TransactionFailure(localStrings.getLocalString( "noTransaction", "Internal Error - Cannot obtain transaction object")); if (domain.getNodeNamed(node) == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchNode", "Node {0} does not exist.", node)); throw new TransactionFailure(localStrings.getLocalString( "Server.cannotSpecifyBothConfigAndCluster", "A configuration name and cluster name cannot both be specified.")); Cluster c = tx.enroll(cluster); ServerRef newServerRef = c.createChild(ServerRef.class); newServerRef.setRef(instanceName); File configConfigDir = new File(env.getConfigDirPath(), specifiedConfig.getName()); new File(configConfigDir, "docroot").mkdirs(); new File(configConfigDir, "lib/ext").mkdirs(); Configs configs = domain.getConfigs(); Configs writableConfigs = tx.enroll(configs);
public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure { Transaction t = Transaction.getTransaction(param); if (t!=null) { Domain dmn; Application app = dmn.getApplications().getApplication(appName); ConfigBeanProxy app_w = t.enroll(app); ((Application)app_w).setEnabled(String.valueOf(enabled)); servr.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ConfigBeanProxy appRef_w = t.enroll(appRef); ((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled)); break; cluster.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ConfigBeanProxy appRef_w = t.enroll(appRef); ((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled)); break; svr.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ConfigBeanProxy appRef_w = t.enroll(appRef); ((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled)); break;
throw new TransactionFailure(msg); LbConfigs lbconfigs = domain.getExtensionByType(LbConfigs.class); Transaction transaction = new Transaction(); try { ConfigBeanProxy domainProxy = transaction.enroll(domain); lbconfigs = domainProxy.createChild(LbConfigs.class); ((Domain) domainProxy).getExtensions().add(lbconfigs); transaction.commit(); } catch (TransactionFailure ex) { transaction.rollback(); String msg = localStrings.getLocalString("LbConfigsCreationFailed", "Creation of parent element lb-configs failed"); throw new TransactionFailure(msg, ex); } catch (RetryableException ex) { transaction.rollback(); String msg = localStrings.getLocalString("LbConfigsCreationFailed", "Creation of parent element lb-configs failed"); throw new TransactionFailure(msg, ex); if (domain.getClusterNamed(target) != null) { ClusterRef cRef = instance.createChild(ClusterRef.class); cRef.setRef(target);
private static boolean setInternalProperty(LbConfig lc, String propertyName) { Property property = lc.getProperty(propertyName); Transaction transaction = new Transaction(); try { if (property == null) { ConfigBeanProxy lcProxy = transaction.enroll(lc); property = lcProxy.createChild(Property.class); property.setName(propertyName); ((LbConfig)lcProxy).getProperty().add(property); } else { ConfigBeanProxy propertyProxy = transaction.enroll(property); ((Property)propertyProxy).setValue(String.valueOf( (new Date()).getTime())); transaction.commit(); } catch (Exception ex) { transaction.rollback(); Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER);
Applications apps_w = t.enroll(applications); apps_w.getModules().add(app_w); if (applicationInfo != null) { ConfigBeanProxy servr_w = t.enroll(servr); ConfigBeanProxy cluster_w = t.enroll(cluster); ApplicationRef appRef = cluster_w.createChild(ApplicationRef.class); setAppRefAttributes(appRef, deployParams); ConfigBeanProxy svr_w = t.enroll(svr); ApplicationRef appRef2 = svr_w.createChild(ApplicationRef.class); setAppRefAttributes(appRef2, deployParams); t.rollback(); throw e; } catch (Exception e) { t.rollback(); throw new TransactionFailure(e.getMessage(), e); t.commit(); } catch (RetryableException e) { System.out.println("Retryable..."); t.rollback(); } catch (TransactionFailure e) { t.rollback(); throw e;
String instanceConfig = child.getConfigRef(); final Config config = configs.getConfigByName(instanceConfig); Transaction t = Transaction.getTransaction(parent); throw new TransactionFailure(msg); if(config == null || domain.getReferenceContainersOf(config).size() > 1 || !instanceConfig.equals(child.getName() + "-config")) return; File configConfigDir = new File(env.getConfigDirPath(), config.getName()); FileUtils.whack(configConfigDir); Configs c = t.enroll(configs); List<Config> configList = c.getConfig(); configList.remove(config); localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig);
Logger logger = ConfigApiLoggerInfo.getLogger(); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class); Transaction t = Transaction.getTransaction(instance); throw new TransactionFailure(localStrings.getLocalString("cannot.execute.command", "Cluster software is not installed")); config = habitat.<Config>getAllServices(Config.class).iterator().next(); logger.log(Level.WARNING,ConfigApiLoggerInfo.noDefaultConfigFound, new Object[]{config.getName(), instance.getName()}); Configs configs = domain.getConfigs(); Configs writableConfigs = t.enroll(configs); final String configName = instance.getName() + "-config"; instance.setConfigRef(configName); if (config != null) { String propName = String.format("GMS_LISTENER_PORT-%s", instanceName); if (config.getProperty(propName) == null ) { Config writeableConfig = t.enroll(config); SystemProperty gmsListenerPortSysProp = instance.createChild(SystemProperty.class); gmsListenerPortSysProp.setName(propName); gmsListenerPortSysProp.setValue(TCPPORT); writeableConfig.getSystemProperty().add(gmsListenerPortSysProp); throw new TransactionFailure("Cannot add un-named resources to the new server instance");
Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class); Transaction t = Transaction.getTransaction(instance); throw new TransactionFailure(localStrings.getLocalString("cannot.execute.command", "Cluster software is not installed")); "Cluster.no_default_config_found", "No default config found, using config {0} as the default config for the cluster {1}", config.getName(), instance.getName())); Configs configs = domain.getConfigs(); Configs writableConfigs = t.enroll(configs); final String configName = instance.getName() + "-config"; instance.setConfigRef(configName); Config specifiedConfig = domain.getConfigs().getConfigByName(configRef); if (specifiedConfig == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchConfig", "Configuration {0} does not exist.", configRef)); for (Resource resource : domain.getResources().getResources()) { if (resource.getObjectType().equals("system-all") || resource.getObjectType().equals("system-instance")) { String name=null; throw new TransactionFailure("Cannot add un-named resources to the new server instance");
LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Server.class); final ActionReport report = context.getActionReport(); Transaction t = Transaction.getTransaction(parent); Cluster cluster = domain.getClusterForInstance(child.getName()); boolean isStandAlone = cluster == null ? true : false; if (config != null && domain.getReferenceContainersOf(config).size() > 1) { return; File configConfigDir = new File(env.getConfigDirPath(), config.getName()); FileUtils.whack(configConfigDir); Configs c = t.enroll(configs); List<Config> configList = c.getConfig(); configList.remove(config); localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig); if (t != null) { try { Cluster c = t.enroll(cluster);
Logger logger = LogDomains.getLogger(LoadBalancer.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LoadBalancer.class); Transaction t = Transaction.getTransaction(parent); LbConfig lbConfig = domain.getExtensionByType(LbConfigs.class).getLbConfig(lbConfigName); for (LoadBalancer lb:domain.getExtensionByType(LoadBalancers.class).getLoadBalancer()) { if (!lb.getName().equals(lbName) && lb.getLbConfigName().equals(lbConfigName)) { report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); throw new TransactionFailure(msg); LbConfigs configs = domain.getExtensionByType(LbConfigs.class); try { if (t != null) { LbConfigs c = t.enroll(configs); List<LbConfig> configList = c.getLbConfig(); configList.remove(lbConfig); localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName);
public void unregisterTenantWithAppInDomainXML( final String appName, final String tenantName ) throws TransactionFailure, RetryableException { final com.sun.enterprise.config.serverbeans.Application app = applications.getApplication(appName); if (app == null) { throw new IllegalArgumentException("Application " + appName + " not found"); } final AppTenants appTenants = app.getAppTenants(); final AppTenant appTenant = appTenants.getAppTenant(tenantName); if (appTenant == null) { throw new IllegalArgumentException("Tenant " + tenantName + " not provisioned for application " + appName); } Transaction t = new Transaction(); final AppTenants appTenants_w = t.enroll(appTenants); appTenants_w.getAppTenant().remove(appTenant); t.commit(); }
public Transaction prepareAppConfigChanges(final DeploymentContext context) throws TransactionFailure { final Properties appProps = context.getAppProps(); final DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class); Transaction t = new Transaction(); try { // prepare the application element ConfigBean newBean = ((ConfigBean)ConfigBean.unwrap(applications)).allocate(Application.class); Application app = newBean.createProxy(); Application app_w = t.enroll(app); setInitialAppAttributes(app_w, deployParams, appProps, context); context.addTransientAppMetaData(ServerTags.APPLICATION, app_w); } catch(TransactionFailure e) { t.rollback(); throw e; } catch (Exception e) { t.rollback(); throw new TransactionFailure(e.getMessage(), e); } return t; }
final Transaction t = Transaction.getTransaction(domain_w); final TopLevelContext topLevelContext = new TopLevelContext(t, domain_w); final Work<TopLevelContext> step = it.next(); if ( ! step.run(topLevelContext) ) { t.rollback(); return Boolean.FALSE; final Configs configs = domain_w.getConfigs(); for (Config c : configs.getConfig()) { final Config c_w = t.enroll(c); ConfigLevelContext configLevelContext = new ConfigLevelContext(topLevelContext, c_w); final Work<ConfigLevelContext> step = it.next(); if ( ! step.run(configLevelContext)) { t.rollback(); return Boolean.FALSE;
private Protocols writableProtocols() throws TransactionFailure { if (protocols_w == null) { final NetworkConfig nc = config_w.getNetworkConfig(); if (nc == null) { return null; } final Protocols p = nc.getProtocols(); protocols_w = t.enroll(p); } return protocols_w; }
Logger logger = LogDomains.getLogger(LoadBalancer.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LoadBalancer.class); Transaction t = Transaction.getTransaction(parent); LbConfig lbConfig = domain.getLbConfigs().getLbConfig(lbConfigName); for (LoadBalancer lb:domain.getLoadBalancers().getLoadBalancer()) { if (!lb.getName().equals(lbName) && lb.getLbConfigName().equals(lbConfigName)) { report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); throw new TransactionFailure(msg); LbConfigs configs = domain.getLbConfigs(); try { if (t != null) { LbConfigs c = t.enroll(configs); List<LbConfig> configList = c.getLbConfig(); configList.remove(lbConfig); localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName);
public Object run(Domain d) throws PropertyVetoException, TransactionFailure { Nodes nodes=d.createChild(Nodes.class); Transaction t = Transaction.getTransaction(d); if (t==null) return null; d.setNodes(nodes); s = t.enroll(s); s.setNodeRef(s.getNodeAgentRef()); s.setNodeAgentRef(null); d.setNodeAgents(null); return null;