public void clearCache(final String vdbName, final int version, final String cacheType) {

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("clear-cache");
    operation.get(ADDRESS).set(address);
    operation.get("cache-type").set(new ModelNode().set(cacheType));
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            Console.info(
                "Cache "
                    + cacheType
                    + " on VDB = "
                    + vdbName
                    + "."
                    + version
                    + " has been cleared");
          }

          @Override
          public void onFailure(Throwable caught) {
            Console.error(
                "Failed to clear Cache " + cacheType + " on VDB = " + vdbName + "." + version,
                caught.getMessage());
          }
        });
  }
Example #2
0
  @Override
  public void deleteXADataSource(XADataSource dataSource, final AsyncCallback<Boolean> callback) {

    AddressBinding address = xadsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), dataSource.getName());

    ModelNode operation = xaDataSourceAdapter.fromEntity(dataSource);
    operation.get(OP).set(REMOVE);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            boolean wasSuccessful = responseIndicatesSuccess(result);
            callback.onSuccess(wasSuccessful);
          }
        });
  }
Example #3
0
  private void parseJpaResources(ModelNode response, List<JPADeployment> jpaUnits) {

    List<ModelNode> deployments = response.get(RESULT).asList();

    for (ModelNode deployment : deployments) {
      ModelNode deploymentValue = deployment.get(RESULT).asObject();

      if (deploymentValue.hasDefined("hibernate-persistence-unit")) {

        List<Property> units = deploymentValue.get("hibernate-persistence-unit").asPropertyList();

        for (Property unit : units) {

          JPADeployment jpaDeployment = factory.jpaDeployment().as();
          ModelNode unitValue = unit.getValue();
          System.out.println(unitValue);
          String tokenString = unit.getName();
          String[] tokens = tokenString.split("#");
          jpaDeployment.setDeploymentName(tokens[0]);
          jpaDeployment.setPersistenceUnit(tokens[1]);

          // https://issues.jboss.org/browse/AS7-5157
          boolean enabled =
              unitValue.hasDefined("enabled") ? unitValue.get("enabled").asBoolean() : false;
          jpaDeployment.setMetricEnabled(enabled);

          jpaUnits.add(jpaDeployment);
        }
      }
    }
  }
  public void onReloadServerConfig() {
    final ModelNode operation = new ModelNode();
    operation.get(OP).set("reload");
    operation.get(ADDRESS).setEmptyList();

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(
                  Console.MESSAGES.failed("Reload Server"), response.getFailureDescription());
            } else {
              pollState();
            }
          }

          @Override
          public void onFailure(Throwable caught) {
            Console.error(Console.MESSAGES.failed("Reload Server"), caught.getMessage());
          }
        });
  }
  public void onSuspendServer(Long value) {

    closeDialoge();

    final ModelNode operation = new ModelNode();
    operation.get(OP).set("suspend");
    operation.get(ADDRESS).setEmptyList();
    operation.get("timeout").set(value);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(response.getFailureDescription());
            } else {
              Console.info("Successfully suspended server");
              loadServer();
            }
          }
        });
  }
  @Override
  public void onRemove(final Property property) {
    ResourceAddress address = addressTemplate.resolve(statementContext);
    ModelNode op = new ModelNode();
    op.get(ADDRESS).set(address);
    op.get(OP).set("map-remove");
    op.get(NAME).set(attribute);
    op.get("key").set(property.getName());
    dispatcher.execute(
        new DMRAction(op),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(final Throwable caught) {
            onRemoveFailed(property, caught);
          }

          @Override
          public void onSuccess(final DMRResponse result) {
            ModelNode response = result.get();
            if (response.isFailure()) {
              onRemoveFailed(property, new RuntimeException(response.getFailureDescription()));
            } else {
              onRemoveSuccess(property);
              Console.getEventBus()
                  .fireEvent(new PropertyRemovedEvent(addressTemplate, attribute, property));
            }
          }
        });
  }
  public void tryDelete(final Server server) {

    // check if instance exist
    ModelNode operation = new ModelNode();
    operation.get(ADDRESS).add("host", hostSelection.getName());
    operation.get(ADDRESS).add("server", server.getName());
    operation.get(OP).set(READ_RESOURCE_OPERATION);

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable throwable) {
            performDeleteOperation(server);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            String outcome = response.get(OUTCOME).asString();

            Boolean serverIsRunning = outcome.equals(SUCCESS) ? Boolean.TRUE : Boolean.FALSE;
            if (!serverIsRunning) performDeleteOperation(server);
            else
              Console.error(
                  "Failed to delete server configuration",
                  "The server instance is still running: " + server.getName());
          }
        });
  }
  public void getSchema(String vdbName, int version, String modelName) {
    if (!isServerActive()) {
      getView().setModelSchema("No Active Server Found");
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("get-schema");
    operation.get(ADDRESS).set(address);
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));
    operation.get("model-name").set(new ModelNode().set(modelName));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              getView().setModelSchema(response.get(RESULT).asString());
            } else {
              getView().setModelSchema(null);
            }
          }
        });
  }
  public void getSessions(final String vdbName, final int version) {
    if (!isServerActive()) {
      getView().setVDBRequests(null);
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("list-sessions");
    operation.get(ADDRESS).set(address);
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              List<Session> sessions = sessionAdaptor.fromDMRList(response.get(RESULT).asList());
              getView().setVDBSessions(vdbName, version, sessions);
            } else {
              getView().setVDBRequests(null);
            }
          }
        });
  }
  public void getQueryPlan(Request request) {
    if (!isServerActive()) {
      getView().setQueryPlan("No Server Found");
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("get-query-plan");
    operation.get(ADDRESS).set(address);
    operation.get("session").set(new ModelNode().set(request.getSessionId()));
    operation.get("execution-id").set(new ModelNode().set(request.getExecutionId()));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            String plan = null;
            if (response.get(RESULT).isDefined()) {
              plan = response.get(RESULT).asString();
            }
            if (plan != null && !plan.trim().isEmpty()) {
              getView().setQueryPlan(plan);
            } else {
              getView()
                  .setQueryPlan(
                      "<node name=\"query\"><property name=\"noplan\">No Plan found, query might have finished executing!</property></node>");
            }
          }
        });
  }
  public void cancelRequest(final Request request) {
    if (!isServerActive()) {
      getView().cancelSubmitted(request);
    }
    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("cancel-request");
    operation.get(ADDRESS).set(address);
    operation.get("session").set(new ModelNode().set(request.getSessionId()));
    operation.get("execution-id").set(new ModelNode().set(request.getExecutionId()));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              getView().cancelSubmitted(request);
              Console.info(
                  "Query Cancel Submitted. Session Id:"
                      + request.getSessionId()
                      + ", Execution Id:"
                      + request.getExecutionId());
            } else {
              getView().cancelSubmitted(null);
            }
          }
        });
  }
  public void getRequests(String vdbName, int version, boolean includeSourceQueries) {
    if (!isServerActive()) {
      getView().setVDBRequests(null);
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("list-requests-per-vdb");
    operation.get(ADDRESS).set(address);
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));
    operation.get("include-source").set(new ModelNode().set(includeSourceQueries));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              List<Request> requests = requestAdaptor.fromDMRList(response.get(RESULT).asList());
              getView().setVDBRequests(requests);
            } else {
              getView().setVDBRequests(null);
            }
          }
        });
  }
  public void getEngineStatistics() {
    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid"); // $NON-NLS-1$  //$NON-NLS-2$
    ModelNode operation = new ModelNode();
    operation.get(OP).set("engine-statistics"); // $NON-NLS-1$
    operation.get(ADDRESS).set(address);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              EngineStatistics stats = runtimeAdaptor.fromDMR(response.get(RESULT));
              getView().setEngineStatistics(stats);
            } else {
              getView().setEngineStatistics(null);
            }
          }

          @Override
          public void onFailure(Throwable caught) {
            Console.error(
                "Failed to retrieve query engine statistics for Teiid", caught.getMessage());
          }
        });
  }
  public void reloadVDB(final String vdbName, final int version) {

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("restart-vdb");
    operation.get(ADDRESS).set(address);
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            Console.info("VDB " + vdbName + "." + version + " has been submitted for reload");
            getView().vdbReloaded(vdbName, version);
          }

          @Override
          public void onFailure(Throwable caught) {
            Console.error(
                "Failed to reload the VDB = " + vdbName + "." + version, caught.getMessage());
          }
        });
  }
Example #15
0
  public void onSave(final Modcluster editedEntity, Map<String, Object> changeset) {

    ModelNode address = new ModelNode();
    address.get(ADDRESS).set(Baseadress.get());
    address.get(ADDRESS).add("subsystem", "modcluster");
    address.get(ADDRESS).add("mod-cluster-config", "configuration");

    ModelNode operation = adapter.fromChangeset(changeset, address);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(
                  Console.MESSAGES.modificationFailed("Modcluster Subsystem"),
                  response.getFailureDescription());
            } else {
              Console.info(Console.MESSAGES.modified("Modcluster Subsystem"));
            }

            loadModcluster();
          }
        });
  }
  public void terminateSession(final Session session) {
    if (!isServerActive()) {
      getView().terminateSessionSubmitted(session);
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("terminate-session");
    operation.get(ADDRESS).set(address);
    operation.get("session").set(new ModelNode().set(session.getSessionId()));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              getView().terminateSessionSubmitted(session);
              Console.info("Terminate Session Submitted. Session Id:" + session.getSessionId());
            } else {
              getView().terminateSessionSubmitted(null);
            }
          }
        });
  }
Example #17
0
  public void onClearSslConfig() {
    ModelNode removeOp = new ModelNode();
    removeOp.get(ADDRESS).set(Baseadress.get());
    removeOp.get(ADDRESS).add("subsystem", "modcluster");
    removeOp.get(ADDRESS).add("mod-cluster-config", "configuration");
    removeOp.get(ADDRESS).add("ssl", "configuration");
    removeOp.get(OP).set(REMOVE);

    dispatcher.execute(
        new DMRAction(removeOp),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(
                  Console.MESSAGES.deletionFailed("SSL Config"), response.getFailureDescription());
            } else {
              Console.info(Console.MESSAGES.deleted("SSL Config"));
            }

            loadModcluster();
          }
        });
  }
  public void changeConnectionType(final String vdbName, final int version, final String connType) {
    if (!isServerActive()) {
      return;
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("change-vdb-connection-type");
    operation.get(ADDRESS).set(address);
    operation.get("connection-type").set(new ModelNode().set(connType));
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            getView().connectionTypeChanged(vdbName, version);
            Console.info(
                "Changing Connection type to "
                    + connType
                    + " on VDB = "
                    + vdbName
                    + "."
                    + version
                    + " has been cleared");
          }
        });
  }
Example #19
0
  public void restart() {
    ModelNode restartNode = new ModelNode();
    if (!bootstrapContext.isStandalone()) {
      restartNode.get(ADDRESS).add("host", domainManager.getSelectedHost());
    }
    restartNode.get(OP).set(SHUTDOWN);
    restartNode.get("restart").set(true);

    final RestartModal restartModal = new RestartModal();
    restartModal.center();

    RestartOp restartOp = new RestartOp(dispatcher);
    restartOp.start(
        dispatcher,
        restartNode,
        new TimeoutOperation.Callback() {
          @Override
          public void onSuccess() {
            // TODO Doesn't need a full reload if a non-dc host was patched
            Window.Location.reload();
          }

          @Override
          public void onTimeout() {
            // TODO Is there another way out?
            restartModal.timeout();
          }

          @Override
          public void onError(final Throwable caught) {
            // TODO Is there another way out?
            restartModal.error();
          }
        });
  }
  public void getCacheStatistics() {
    if (!isServerActive()) {
      return;
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("cache-statistics");
    operation.get(ADDRESS).set(address);
    operation.get("cache-type").set(new ModelNode().set("QUERY_SERVICE_RESULT_SET_CACHE"));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              CacheStatistics cache = cacheAdaptor.fromDMR(response.get(RESULT));
              getView().setCacheStatistics(cache);
            } else {
              getView().setCacheStatistics(null);
            }
          }
        });
  }
Example #21
0
  private void loadSubsystem() {

    ModelNode operation = beanMetaData.getAddress().asResource(Baseadress.get());
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(RECURSIVE).set(true);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(Console.MESSAGES.unknown_error(), response.getFailureDescription());
            } else {
              ModelNode payload = response.get(RESULT).asObject();
              JMXSubsystem jmxSubsystem = adapter.fromDMR(payload);

              // TODO: https://issues.jboss.org/browse/AS7-3566
              if (payload.hasDefined("remoting-connector")) {
                List<Property> connectorList = payload.get("remoting-connector").asPropertyList();
                if (!connectorList.isEmpty()) {
                  Property item = connectorList.get(0);
                  ModelNode jmxConnector = item.getValue();
                  jmxSubsystem.setRegistryBinding(jmxConnector.get("registry-binding").asString());
                  jmxSubsystem.setServerBinding(jmxConnector.get("server-binding").asString());
                }
              }

              getView().updateFrom(jmxSubsystem);
            }
          }
        });
  }
  public void getSourceRequests(final Request selection) {
    if (!isServerActive()) {
      getView().setSourceRequests(selection, null);
    }

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("list-requests-per-session");
    operation.get(ADDRESS).set(address);
    operation.get("session").set(new ModelNode().set(selection.getSessionId()));
    operation.get("include-source").set(new ModelNode().set(true));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              List<Request> requests = requestAdaptor.fromDMRList(response.get(RESULT).asList());
              getView().setSourceRequests(selection, requests);
            } else {
              getView().setSourceRequests(selection, null);
            }
          }
        });
  }
  private void loadServer() {

    final ModelNode operation = new ModelNode();
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(INCLUDE_RUNTIME).set(true);
    operation.get(ADDRESS).setEmptyList();

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(response.getFailureDescription());
            } else {
              // TODO: only works when this response changes the reload state
              ModelNode model = response.get(RESULT);

              boolean isRunning = model.get("server-state").asString().equalsIgnoreCase("RUNNING");
              StandaloneServer server =
                  new StandaloneServer(
                      !isRunning, SuspendState.valueOf(model.get("suspend-state").asString()));

              getView().updateServer(server);
            }
          }
        });
  }
Example #24
0
  public void getPatchInfo(final PatchInfo patch, final AsyncCallback<PatchInfo> callback) {
    ModelNode patchInfoOp = baseAddress();
    patchInfoOp.get(OP).set("patch-info");
    patchInfoOp.get("patch-id").set(patch.getId());

    dispatcher.execute(
        new DMRAction(patchInfoOp),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(final Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(final DMRResponse response) {
            ModelNode result = response.get();
            if (!result.hasDefined(OUTCOME) || result.isFailure()) {
              callback.onFailure(new RuntimeException(result.getFailureDescription()));
            } else {
              ModelNode payload = result.get(RESULT);
              patch.setIdentityName(payload.get("identity-name").asString());
              patch.setIdentityVersion(payload.get("identity-version").asString());
              patch.setDescription(payload.get("description").asString());
              if (payload.get("link").isDefined()) {
                patch.setLink(payload.get("link").asString());
              } else {
                patch.setLink("");
              }
              callback.onSuccess(patch);
            }
          }
        });
  }
Example #25
0
  @Override
  public void createDataSource(
      final DataSource datasource, final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    AddressBinding address = dsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), datasource.getName());

    ModelNode operation = dataSourceAdapter.fromEntity(datasource);
    operation.get(OP).set(ADD);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode modelNode = result.get();
            boolean wasSuccessful = modelNode.get(OUTCOME).asString().equals(SUCCESS);

            callback.onSuccess(new ResponseWrapper<Boolean>(wasSuccessful, modelNode));
          }
        });
  }
Example #26
0
  public void rollback(
      final PatchInfo patchInfo,
      final boolean resetConfiguration,
      final boolean overrideAll,
      final AsyncCallback<Void> callback) {
    ModelNode rollbackOp = baseAddress();
    rollbackOp.get(OP).set("rollback");
    rollbackOp.get("patch-id").set(patchInfo.getId());
    rollbackOp.get("reset-configuration").set(resetConfiguration);
    rollbackOp.get("override-all").set(overrideAll);

    dispatcher.execute(
        new DMRAction(rollbackOp),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(final Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(final DMRResponse response) {
            ModelNode result = response.get();
            if (!result.hasDefined(OUTCOME) || result.isFailure()) {
              callback.onFailure(new RuntimeException(result.getFailureDescription()));
            } else {
              callback.onSuccess(null);
            }
          }
        });
  }
Example #27
0
  @Override
  public void deleteXAConnectionProperty(
      String reference, PropertyRecord prop, final AsyncCallback<Boolean> callback) {
    AddressBinding address = xadsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), reference);
    operation.get(ADDRESS).add("xa-datasource-properties", prop.getKey());
    operation.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    operation.get(OP).set(REMOVE);

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable throwable) {
            callback.onFailure(throwable);
          }

          @Override
          public void onSuccess(DMRResponse response) {
            ModelNode result = response.get();
            callback.onSuccess(ModelAdapter.wasSuccess(result));
          }
        });
  }
Example #28
0
  public HostControllerOpV3(
      final LifecycleOperation op,
      final LifecycleCallback callback,
      final DispatchAsync dispatcher,
      final HostInformationStore hostInformationStore,
      final String host,
      final List<Server> server) {

    super(op, callback);

    this.dispatcher = dispatcher;
    this.hostInformationStore = hostInformationStore;
    this.host = host;

    this.node = new ModelNode();
    this.node.get(ADDRESS).setEmptyList();
    this.node.get(OP).set(COMPOSITE);
    List<ModelNode> steps = new LinkedList<ModelNode>();

    for (Server serverRef : server) {
      ModelNode serverStateOp = new ModelNode();
      serverStateOp.get(OP).set(READ_ATTRIBUTE_OPERATION);
      serverStateOp.get(ADDRESS).add("host", host);
      serverStateOp.get(ADDRESS).add("server-config", serverRef.getName());
      serverStateOp.get(NAME).set("status");
      steps.add(serverStateOp);
    }

    this.node.get(STEPS).set(steps);
  }
Example #29
0
  private void loadSubsystem() {

    ModelNode operation = beanMetaData.getAddress().asResource(Baseadress.get());
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(RECURSIVE).set(true);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            if (response.isFailure()) {
              Console.error(Console.MESSAGES.unknown_error(), response.getFailureDescription());
            } else {
              ModelNode payload = response.get(RESULT).asObject();
              JMXSubsystem jmxSubsystem = adapter.fromDMR(payload);

              if (payload.hasDefined("remoting-connector")) {
                List<Property> connectorList = payload.get("remoting-connector").asPropertyList();
                if (!connectorList.isEmpty()) {
                  Property item = connectorList.get(0);
                  ModelNode jmxConnector = item.getValue();
                  jmxSubsystem.setMgmtEndpoint(
                      jmxConnector.get("use-management-endpoint").asBoolean());
                }
              }

              getView().updateFrom(jmxSubsystem);
            }
          }
        });
  }
  public void getSessions(final String vdbName, final int version) {

    ModelNode address = RuntimeBaseAddress.get();
    address.add("subsystem", "teiid");
    ModelNode operation = new ModelNode();
    operation.get(OP).set("list-sessions");
    operation.get(ADDRESS).set(address);
    operation.get("vdb-name").set(new ModelNode().set(vdbName));
    operation.get("vdb-version").set(new ModelNode().set(version));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {
          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();
            if (response.get(RESULT).isDefined()) {
              List<Session> sessions = sessionAdaptor.fromDMRList(response.get(RESULT).asList());
              getView().setVDBSessions(vdbName, version, sessions);
            } else {
              getView().setVDBRequests(null);
            }
          }

          @Override
          public void onFailure(Throwable caught) {
            Console.error(
                "Failed to get current sessions for vdb = " + vdbName + "." + version,
                caught.getMessage());
          }
        });
  }