Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into FISH-7959-fix-mul…
Browse files Browse the repository at this point in the history
…tirelease-jar-lookup
  • Loading branch information
breakponchito committed Oct 27, 2023
2 parents 34153c8 + 4b0a9cf commit cc1f872
Show file tree
Hide file tree
Showing 13 changed files with 1,047 additions and 900 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright 2023 [Payara Foundation and/or its affiliates]

package com.sun.enterprise.connectors.jms.util;

Expand All @@ -60,7 +61,7 @@
import com.sun.enterprise.util.SystemPropertyConstants;
import com.sun.enterprise.util.zip.ZipFile;
import com.sun.enterprise.util.zip.ZipFileException;
import com.sun.logging.LogDomains;
import fish.payara.enterprise.config.serverbeans.DeploymentGroup;

import org.glassfish.ejb.config.MdbContainer;
import org.glassfish.internal.api.Globals;
Expand Down Expand Up @@ -154,23 +155,44 @@ public static boolean isClustered(List clusters, String instanceName) {
return (enableClustering() && isServerClustered(clusters,
instanceName));
}
/**

/**
* Return true if the given server instance is part of a cluster.
*/
public static boolean isServerClustered(List clusters, String instanceName)
{
public static boolean isServerClustered(List clusters, String instanceName) {
return (getClusterForServer(clusters, instanceName) != null);
}
public static Cluster getClusterForServer(List clusters, String instanceName){

public static Cluster getClusterForServer(List<Cluster> clusters, String instanceName){
//Return the server only if it is part of a cluster (i.e. only if a cluster
//has a reference to it).
for (int i = 0; i < clusters.size(); i++) {
final List servers = ((Cluster)clusters.get(i)).getInstances();
for (int j = 0; j < servers.size(); j++) {
if (((Server)servers.get(j)).getName().equals(instanceName)) {
for (Cluster cluster : clusters) {
final List<Server> servers = cluster.getInstances();
for (Server server : servers) {
if (server.getName().equals(instanceName)) {
// check to see if the server exists as a sanity check.
// NOTE: we are not checking for duplicate server instances here.
return (Cluster) clusters.get(i);
return cluster;
}
}
}
return null;
}

/**
* Return true if the given server instance is part of a deployment group.
*/
public static boolean isServerInDeploymentGroup(List<DeploymentGroup> deploymentGroupList, String instanceName)
{
return (getDeploymentGroupForServer(deploymentGroupList, instanceName) != null);
}

public static DeploymentGroup getDeploymentGroupForServer(List<DeploymentGroup> deploymentGroupList, String instanceName){
for (DeploymentGroup deploymentGroup : deploymentGroupList) {
final List<Server> servers = deploymentGroup.getInstances();
for (Server server : servers) {
if (server.getName().equals(instanceName)) {
return deploymentGroup;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2017-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2023] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.config.serverbeans;

Expand Down Expand Up @@ -771,7 +771,7 @@ public static boolean isCurrentInstanceMatchingTarget(Domain d,

public static List<Server> getServersInTarget(
Domain me, String target) {
List<Server> servers = new ArrayList<Server>();
List<Server> servers = new ArrayList<>();
Server server = me.getServerNamed(target);
if (server != null) {
servers.add(server);
Expand All @@ -795,7 +795,7 @@ public static List<ApplicationRef> getApplicationRefsInTarget(
}

public static List<String> getTargets(final Domain me, final String tgt) {
List<String> targets = new ArrayList<String>();
List<String> targets = new ArrayList<>();
if (!tgt.equals("domain")) {
targets.add(tgt);
} else {
Expand Down Expand Up @@ -920,13 +920,12 @@ public static List<String> getAllTargets(Domain d) {
targets.add(server.getName());
}
}
for (Cluster cluster : d.getClusters().getCluster()) {
targets.add(cluster.getName());
}

for (DeploymentGroup dg : d.getDeploymentGroups().getDeploymentGroup()) {
targets.add(dg.getName());
}
for (Cluster cluster : d.getClusters().getCluster()) {
targets.add(cluster.getName());
}
for (DeploymentGroup dg : d.getDeploymentGroups().getDeploymentGroup()) {
targets.add(dg.getName());
}
return targets;
}

Expand Down Expand Up @@ -1005,25 +1004,27 @@ public static String getVirtualServersForApplication(Domain d,
}
}

public static String getEnabledForApplication(Domain d,
String target, String appName) {
ApplicationRef appRef = d.getApplicationRefInTarget(
appName, target);
if (appRef != null) {
public static String getEnabledForApplication(Domain d,
String target, String appName) {
ApplicationRef appRef = d.getApplicationRefInTarget(
appName, target);
if (appRef != null) {
return appRef.getEnabled();
} else {
} else {
return null;
}
}

public static ReferenceContainer getReferenceContainerNamed(Domain d, String name) {
// Clusters and Servers are ReferenceContainers
Cluster c = getClusterNamed(d, name);
}
}

if(c != null)
return c;

return getServerNamed(d, name);
public static ReferenceContainer getReferenceContainerNamed(Domain domain, String name) {
Cluster cluster = getClusterNamed(domain, name);
if (cluster != null) {
return cluster;
}
DeploymentGroup deploymentGroup = getDeploymentGroupNamed(domain, name);
if (deploymentGroup != null) {
return deploymentGroup;
}
return getServerNamed(domain, name);
}

public static List<ReferenceContainer> getReferenceContainersOf(Domain d, Config config) {
Expand Down Expand Up @@ -1052,6 +1053,7 @@ public static List<ReferenceContainer> getAllReferenceContainers(Domain d) {
List<ReferenceContainer> referenceContainers = new LinkedList<ReferenceContainer>();
referenceContainers.addAll(d.getServers().getServer());
referenceContainers.addAll(d.getClusters().getCluster());
referenceContainers.addAll(d.getDeploymentGroups().getDeploymentGroup());
return referenceContainers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2017-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2023] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.config.serverbeans;

Expand Down Expand Up @@ -796,7 +796,7 @@ private void checkAdminPort(final Server instance, final Config config, LocalStr
}

private void setupSupplemental(AdminCommandContext context, final Server instance) {
if (clusterName != null) {
if (clusterName != null || deploymentGroup != null) {
InstanceRegisterInstanceCommandParameters cp = new InstanceRegisterInstanceCommandParameters();
context.getActionReport().
setResultType(InstanceRegisterInstanceCommandParameters.class, cp);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2017-2021 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2017-2023] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -56,6 +56,7 @@
import org.glassfish.api.admin.config.Named;
import org.glassfish.api.admin.config.PropertiesDesc;
import static org.glassfish.config.support.Constants.NAME_SERVER_REGEX;
import org.glassfish.api.admin.config.ReferenceContainer;
import org.jvnet.hk2.config.ConfigSupport;
import org.jvnet.hk2.config.Configured;
import org.jvnet.hk2.config.Dom;
Expand All @@ -71,7 +72,7 @@
*/
@Configured
@NotDuplicateTargetName(message="{dg.duplicate.name}", payload=DeploymentGroup.class)
public interface DeploymentGroup extends Named, Payload, RefContainer, PropertyBag {
public interface DeploymentGroup extends Named, Payload, RefContainer, PropertyBag, ReferenceContainer {

/**
* Sets the deployment group name
Expand Down Expand Up @@ -117,6 +118,35 @@ public interface DeploymentGroup extends Named, Payload, RefContainer, PropertyB

@DuckTyped
void deleteResourceRef(String refName) throws TransactionFailure;

/**
* Returns the DG configuration reference
* @return the config-ref attribute
*/
@DuckTyped
@Override
String getReference();

// five trivial methods that ReferenceContainer's need to implement
@DuckTyped
@Override
boolean isCluster();

@DuckTyped
@Override
boolean isServer();

@DuckTyped
@Override
boolean isDas();

@DuckTyped
@Override
boolean isDeploymentGroup();

@DuckTyped
@Override
boolean isInstance();

/**
* Properties as per {@link org.jvnet.hk2.config.types.PropertyBag}
Expand All @@ -129,14 +159,25 @@ public interface DeploymentGroup extends Named, Payload, RefContainer, PropertyB


class Duck {
public static boolean isCluster(DeploymentGroup me) { return false; }
public static boolean isServer(DeploymentGroup me) { return false; }
public static boolean isInstance(DeploymentGroup me) { return false; }
public static boolean isDas(DeploymentGroup me) { return false; }
public static boolean isDeploymentGroup(DeploymentGroup me) { return true; }

public static String getReference(DeploymentGroup me) {
for (Server server : me.getInstances()) {
return server.getConfigRef();
}
return "";
}

public static List<Server> getInstances(DeploymentGroup me) {

Dom clusterDom = Dom.unwrap(me);
Domain domain =
clusterDom.getHabitat().getService(Domain.class);
Domain domain = clusterDom.getHabitat().getService(Domain.class);

ArrayList<Server> instances = new ArrayList<Server>();
ArrayList<Server> instances = new ArrayList<>();
for (DGServerRef sRef : me.getDGServerRef()) {
Server svr = domain.getServerNamed(sRef.getRef());
// the instance's domain.xml only has its own server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright 2023 [Payara Foundation and/or its affiliates]

package org.glassfish.config.support;

Expand All @@ -50,8 +51,11 @@ public class Constants {
static final String SERVER = "server";
static final String CLUSTERS = "clusters";
static final String CLUSTER = "cluster";
static final String DEPLOYMENT_GROUPS = "deployment-groups";
static final String DEPLOYMENT_GROUP = "deployment-group";
static final String REF = "ref";
static final String SERVER_REF = "server-ref";
static final String DG_SERVER_REF = "dg-server-ref";
static final String CONFIG = "config";
static final String CONFIGS = "configs";
static final String CONFIG_REF = "config-ref";
Expand Down
Loading

0 comments on commit cc1f872

Please sign in to comment.