示例#1
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);
        }
      }
    }
  }
示例#2
0
 private PatchInfo historyToPatchInfo(final ModelNode node) {
   PatchInfo patchInfo = beanFactory.patchInfo().as();
   patchInfo.setId(node.get("patch-id").asString());
   patchInfo.setType(node.get("type").asString());
   patchInfo.setAppliedAt(node.get("applied-at").asString());
   patchInfo.setIdentityName("");
   patchInfo.setIdentityVersion("");
   patchInfo.setDescription("");
   patchInfo.setLink("");
   return patchInfo;
 }
  private List<HostInfo> generateFakeDomain() {
    String[] hostNames = new String[] {"lightning", "eeak-a-mouse", "dirty-harry"};
    String[] groupNames =
        new String[] {
          "staging",
          "production",
          "messaging-back-server-test",
          "uat",
          "messaging",
          "backoffice",
          "starlight"
        };

    int numHosts = 13;
    final List<HostInfo> hostInfos = new ArrayList<HostInfo>();

    for (int i = 0; i < numHosts; i++) {
      // host info
      String name = hostNames[Random.nextInt(2)] + "-" + i;
      boolean isController = (i < 1);

      HostInfo host = new HostInfo(name, isController);
      host.setServerInstances(new ArrayList<ServerInstance>());

      // server instances
      for (int x = 0; x < (Random.nextInt(5) + 1); x++) {
        int groupIndex = Random.nextInt(groupNames.length - 1);
        ServerInstance serverInstance = beanFactory.serverInstance().as();
        serverInstance.setGroup(groupNames[groupIndex]);
        serverInstance.setRunning((groupIndex % 2 == 0));
        if (serverInstance.isRunning()) {
          if (Random.nextBoolean()) {
            serverInstance.setFlag(Random.nextBoolean() ? RESTART_REQUIRED : RELOAD_REQUIRED);
          } else {
            serverInstance.setFlag(null);
          }
        }
        serverInstance.setName(groupNames[groupIndex] + "-" + x);
        serverInstance.setSocketBindings(Collections.<String, String>emptyMap());
        serverInstance.setInterfaces(Collections.<String, String>emptyMap());

        host.getServerInstances().add(serverInstance);
      }
      hostInfos.add(host);
    }
    return hostInfos;
  }