use of io.fabric8.groups.Group in project openflowplugin by opendaylight.
the class FlowCapableNodeLookups method wrapGroupsToMap.
@Nonnull
public static Map<Long, Group> wrapGroupsToMap(@Nullable final List<Group> groups) {
final Map<Long, Group> groupMap;
if (groups == null) {
groupMap = Collections.emptyMap();
} else {
LOG.trace("groups found: {}", groups.size());
groupMap = new HashMap<>();
for (Group group : groups) {
groupMap.put(group.getGroupId().getValue(), group);
}
}
return groupMap;
}
use of io.fabric8.groups.Group in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveAndDivideGroupDiffs.
/**
* Returns a list of safe synchronization steps.
*
* @param nodeId target node
* @param installedGroupsArg groups resent on device
* @param pendingGroups groups configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return list of safe synchronization steps
*/
public static List<ItemSyncBox<Group>> resolveAndDivideGroupDiffs(final NodeId nodeId, final Map<Long, Group> installedGroupsArg, final Collection<Group> pendingGroups, final boolean gatherUpdates) {
final Map<Long, Group> installedGroups = new HashMap<>(installedGroupsArg);
final List<ItemSyncBox<Group>> plan = new ArrayList<>();
while (!Iterables.isEmpty(pendingGroups)) {
final ItemSyncBox<Group> stepPlan = new ItemSyncBox<>();
final Iterator<Group> iterator = pendingGroups.iterator();
final Map<Long, Group> installIncrement = new HashMap<>();
while (iterator.hasNext()) {
final Group group = iterator.next();
final Group existingGroup = installedGroups.get(group.getGroupId().getValue());
if (existingGroup != null) {
if (!gatherUpdates) {
iterator.remove();
} else {
// check buckets and eventually update
if (group.equals(existingGroup)) {
iterator.remove();
} else {
if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId);
stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group));
}
}
}
} else if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
installIncrement.put(group.getGroupId().getValue(), group);
stepPlan.getItemsToPush().add(group);
}
}
if (!stepPlan.isEmpty()) {
// atomic update of installed flows in order to keep plan portions clean of local group dependencies
installedGroups.putAll(installIncrement);
plan.add(stepPlan);
} else if (!pendingGroups.isEmpty()) {
LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, " + "resolving stuck at level {}", nodeId.getValue(), plan.size());
throw new IllegalStateException("Failed to resolve and divide groups when matching preconditions");
}
}
return plan;
}
use of io.fabric8.groups.Group in project fabric8 by jboss-fuse.
the class MQCreateAction method createDTO.
private MQBrokerConfigDTO createDTO() {
if (Strings.isNullOrBlank(username)) {
username = ShellUtils.retrieveFabricUser(session);
}
if (Strings.isNullOrBlank(password)) {
password = ShellUtils.retrieveFabricUserPassword(session);
}
MQBrokerConfigDTO dto = new MQBrokerConfigDTO();
if (config != null) {
dto.setConfigUrl(config);
} else {
if (nossl) {
dto.setConfigUrl("broker.xml");
} else {
dto.setConfigUrl("ssl-broker.xml");
}
}
dto.setData(data);
if (ports != null && ports.length > 0) {
for (String port : ports) {
addConfig(port, dto.getPorts());
}
}
dto.setGroup(group);
dto.setJvmOpts(jvmOpts);
dto.setBrokerName(name);
dto.setProfile(profile);
dto.setClientProfile(clientProfile);
dto.setClientParentProfile(clientParentProfile);
dto.setNetworks(networks);
dto.setNetworksPassword(networksPassword);
dto.setNetworksUserName(networksUserName);
dto.setParentProfile(parentProfile);
dto.setProperties(properties);
if (version == null) {
version = fabricService.getDefaultVersionId();
}
dto.setVersion(version);
dto.setMinimumInstances(minimumInstances);
dto.setReplicas(replicas);
dto.setSsl(!nossl);
dto.setKind(kind);
return dto;
}
use of io.fabric8.groups.Group in project fabric8 by jboss-fuse.
the class GitMasterListener method updateMasterUrl.
/**
* Updates the git master url, if needed.
*/
private void updateMasterUrl(Group<GitNode> group) {
GitNode master = group.master();
String masterUrl = master != null ? master.getUrl() : null;
try {
if (masterUrl != null) {
GitService gitservice = gitService.get();
String substitutedUrl = getSubstitutedData(curator.get(), masterUrl);
if (!Strings.isNotBlank(substitutedUrl)) {
LOGGER.warn("Could not render git master URL {}.", masterUrl);
}
// Catch any possible issue indicating that the URL is invalid.
if (!FabricValidations.isURIValid(substitutedUrl)) {
LOGGER.warn("Not changing master Git URL to \"" + substitutedUrl + "\". There may be pending ZK connection shutdown.");
} else {
gitservice.notifyRemoteChanged(substitutedUrl);
}
}
} catch (Exception e) {
LOGGER.error("Failed to point origin to the new master.", e);
}
}
use of io.fabric8.groups.Group in project fabric8 by jboss-fuse.
the class GitHttpServerRegistrationHandler method activate.
@Activate
void activate(Map<String, ?> configuration) throws Exception {
RuntimeProperties sysprops = runtimeProperties.get();
realm = getConfiguredRealm(sysprops, configuration);
roles = getConfiguredRoles(sysprops, configuration);
dataPath = sysprops.getDataPath();
activateComponent();
group = new ZooKeeperGroup<GitNode>(curator.get(), ZkPath.GIT.getPath(), GitNode.class, new NamedThreadFactory("zkgroup-git-httpreg"));
// if anything went wrong in a previous deactivation we still have to clean up the registry
zkCleanUp(group);
group.add(this);
group.update(createState());
group.start();
}
Aggregations