use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.
the class ProfileMetadata method createMetaTypeObjectDTO.
protected static MetaTypeObjectDTO createMetaTypeObjectDTO(Properties resources, OCD ocd) {
MetaTypeObjectDTO answer = new MetaTypeObjectDTO();
answer.setId(ocd.getID());
answer.setName(localize(resources, ocd.getName()));
answer.setDescription(localize(resources, ocd.getDescription()));
List<MetaTypeAttributeDTO> attributeList = new ArrayList<>();
Map<String, Object> attributes = ocd.getAttributeDefinitions();
if (attributes != null) {
Set<Map.Entry<String, Object>> entries = attributes.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String name = entry.getKey();
Object value = entry.getValue();
if (value instanceof AD) {
AD ad = (AD) value;
MetaTypeAttributeDTO attributeDTO = createMetaTypeAttributeDTO(resources, ocd, name, ad);
if (attributeDTO != null) {
attributeList.add(attributeDTO);
}
}
}
}
answer.setAttributes(attributeList);
return answer;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.
the class WatchAction method doExecute.
@Override
protected Object doExecute() throws Exception {
if (start && stop) {
System.err.println("Please use only one of --start and --stop options!");
return null;
}
if (interval > 0) {
System.out.println("Setting watch interval to " + interval + " ms");
watcher.setInterval(interval);
}
if (stop) {
System.out.println("Stopping watch");
watcher.stop();
}
watcher.setUpload(upload);
if (urls != null) {
if (remove) {
for (String url : urls) {
watcher.remove(url);
}
} else {
for (String url : urls) {
watcher.add(url);
}
}
}
if (start) {
System.out.println("Starting watch");
watcher.start();
}
if (list) {
// list the watched bundles.
TablePrinter printer = new TablePrinter();
printer.columns("url", "profile", "version", "bundle");
for (String url : watcher.getWatchURLs()) {
Map<ProfileVersionKey, Map<String, Parser>> profileArtifacts = watcher.getProfileArtifacts();
if (profileArtifacts.size() > 0) {
Set<Map.Entry<ProfileVersionKey, Map<String, Parser>>> entries = profileArtifacts.entrySet();
for (Map.Entry<ProfileVersionKey, Map<String, Parser>> entry : entries) {
ProfileVersionKey key = entry.getKey();
Map<String, Parser> artifactMap = entry.getValue();
Set<Map.Entry<String, Parser>> artifactMapEntries = artifactMap.entrySet();
for (Map.Entry<String, Parser> artifactMapEntry : artifactMapEntries) {
String location = artifactMapEntry.getKey();
Parser parser = artifactMapEntry.getValue();
if (isSnapshot(parser) || watcher.wildCardMatch(location, url)) {
printer.row(url, key.getProfileId(), key.getVersion(), location);
}
}
}
} else {
printer.row(url, "", "", "");
}
}
printer.print();
} else {
List<String> urls = watcher.getWatchURLs();
if (urls != null && urls.size() > 0) {
System.out.println("Watched URLs: ");
for (String url : watcher.getWatchURLs()) {
System.out.println(url);
}
} else {
System.out.println("No watched URLs");
}
}
return null;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.
the class ProfileMetadata method findMetadataForProfile.
protected void findMetadataForProfile(String versionId, String profileId, MetadataHandler handler) throws Exception {
FabricService service = fabricService.get();
Objects.notNull(service, "FabricService");
ProfileService profileService = service.adapt(ProfileService.class);
Objects.notNull(profileService, "ProfileService");
DownloadManager downloadManager = DownloadManagers.createDownloadManager(service, executorService);
Objects.notNull(downloadManager, "DownloadManager");
Profile immediateProfile = profileService.getProfile(versionId, profileId);
Objects.notNull(immediateProfile, "Profile for versionId: " + versionId + ", profileId: " + profileId);
Profile profile = profileService.getOverlayProfile(immediateProfile);
Set<String> pids = new HashSet<>();
Map<String, File> fileMap = AgentUtils.downloadProfileArtifacts(service, downloadManager, profile);
Set<Map.Entry<String, File>> entries = fileMap.entrySet();
for (Map.Entry<String, File> entry : entries) {
String uri = entry.getKey();
File file = entry.getValue();
if (!file.exists() || !file.isFile()) {
LOG.warn("File " + file + " is not an existing file for " + uri + ". Ignoring");
continue;
}
addMetaTypeInformation(handler, uri, file);
pids.add(uri);
}
// lets check if the MetaType folder exists
if (metaTypeFolder != null && metaTypeFolder.exists() && metaTypeFolder.isDirectory()) {
Set<String> configurationFileNames = profile.getConfigurationFileNames();
for (String configName : configurationFileNames) {
if (configName.endsWith(PROPERTIES_SUFFIX) && configName.indexOf('/') < 0) {
String pid = configName.substring(0, configName.length() - PROPERTIES_SUFFIX.length());
addMetaTypeInformation(pids, handler, pid);
String factoryPid = getFactoryPid(pid);
addMetaTypeInformation(pids, handler, factoryPid);
}
}
}
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.
the class ZooKeeperServerFactory method activateInternal.
private Destroyable activateInternal(BundleContext context, Map<String, ?> configuration) throws Exception {
LOGGER.info("Creating zookeeper server with: {}", configuration);
Properties props = new Properties();
for (Entry<String, ?> entry : configuration.entrySet()) {
props.put(entry.getKey(), entry.getValue());
}
// Remove the dependency on the current dir from dataDir
String dataDir = props.getProperty("dataDir");
if (dataDir != null && !Paths.get(dataDir).isAbsolute()) {
dataDir = runtimeProperties.get().getDataPath().resolve(dataDir).toFile().getAbsolutePath();
props.setProperty("dataDir", dataDir);
}
props.put("clientPortAddress", bootstrapConfiguration.get().getBindAddress());
// Create myid file
String serverId = (String) props.get("server.id");
if (serverId != null) {
props.remove("server.id");
File myId = new File(dataDir, "myid");
if (myId.exists() && !myId.delete()) {
throw new IOException("Failed to delete " + myId);
}
if (myId.getParentFile() == null || (!myId.getParentFile().exists() && !myId.getParentFile().mkdirs())) {
throw new IOException("Failed to create " + myId.getParent());
}
FileOutputStream fos = new FileOutputStream(myId);
try {
fos.write((serverId + "\n").getBytes());
} finally {
fos.close();
}
}
QuorumPeerConfig peerConfig = getPeerConfig(props);
if (!peerConfig.getServers().isEmpty()) {
NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
cnxnFactory.configure(peerConfig.getClientPortAddress(), peerConfig.getMaxClientCnxns());
QuorumPeer quorumPeer = new QuorumPeer();
quorumPeer.setClientPortAddress(peerConfig.getClientPortAddress());
quorumPeer.setTxnFactory(new FileTxnSnapLog(new File(peerConfig.getDataLogDir()), new File(peerConfig.getDataDir())));
quorumPeer.setQuorumPeers(peerConfig.getServers());
quorumPeer.setElectionType(peerConfig.getElectionAlg());
quorumPeer.setMyid(peerConfig.getServerId());
quorumPeer.setTickTime(peerConfig.getTickTime());
quorumPeer.setMinSessionTimeout(peerConfig.getMinSessionTimeout());
quorumPeer.setMaxSessionTimeout(peerConfig.getMaxSessionTimeout());
quorumPeer.setInitLimit(peerConfig.getInitLimit());
quorumPeer.setSyncLimit(peerConfig.getSyncLimit());
quorumPeer.setQuorumVerifier(peerConfig.getQuorumVerifier());
quorumPeer.setCnxnFactory(cnxnFactory);
quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory()));
quorumPeer.setLearnerType(peerConfig.getPeerType());
try {
LOGGER.debug("Starting quorum peer \"{}\" on address {}", quorumPeer.getMyid(), peerConfig.getClientPortAddress());
quorumPeer.start();
LOGGER.debug("Started quorum peer \"{}\"", quorumPeer.getMyid());
} catch (Exception e) {
LOGGER.warn("Failed to start quorum peer \"{}\", reason : {} ", quorumPeer.getMyid(), e.getMessage());
quorumPeer.shutdown();
throw e;
}
// Register stats provider
ClusteredServer server = new ClusteredServer(quorumPeer);
registration = context.registerService(QuorumStats.Provider.class, server, null);
return server;
} else {
ServerConfig serverConfig = getServerConfig(peerConfig);
ZooKeeperServer zkServer = new ZooKeeperServer();
FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir()));
zkServer.setTxnLogFactory(ftxn);
zkServer.setTickTime(serverConfig.getTickTime());
zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());
NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory() {
protected void configureSaslLogin() throws IOException {
}
};
cnxnFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
try {
LOGGER.debug("Starting ZooKeeper server on address {}", peerConfig.getClientPortAddress());
cnxnFactory.startup(zkServer);
LOGGER.debug("Started ZooKeeper server");
} catch (Exception e) {
LOGGER.warn("Failed to start ZooKeeper server, reason : {}", e);
cnxnFactory.shutdown();
throw e;
}
// Register stats provider
SimpleServer server = new SimpleServer(zkServer, cnxnFactory);
registration = context.registerService(ServerStats.Provider.class, server, null);
startCleanupManager(serverConfig, props);
return server;
}
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.
the class RhqMetricsStorage method store.
@Override
public void store(String type, long timestamp, QueryResult queryResult) {
assertValid();
if (metricsService == null) {
throw new IllegalStateException("No metricsService available!");
}
Map<String, Result<?>> results = queryResult.getResults();
if (results != null) {
Set<RawNumericMetric> data = new HashSet<>();
Set<Map.Entry<String, Result<?>>> entries = results.entrySet();
for (Map.Entry<String, Result<?>> entry : entries) {
String key = entry.getKey();
Result<?> result = entry.getValue();
if (result instanceof MBeanOpersResult) {
MBeanOpersResult opersResult = (MBeanOpersResult) result;
List<MBeanOperResult> operResults = opersResult.getResults();
if (operResults != null) {
for (MBeanOperResult operResult : operResults) {
Object value = operResult.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, opersResult.getRequest());
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
} else if (result instanceof MBeanAttrsResult) {
MBeanAttrsResult attrsResult = (MBeanAttrsResult) result;
List<MBeanAttrResult> attrResults = attrsResult.getResults();
if (attrResults != null) {
for (MBeanAttrResult attrResult : attrResults) {
Map<String, Object> attrs = attrResult.getAttrs();
if (attrs != null) {
Set<Map.Entry<String, Object>> attrEntries = attrs.entrySet();
for (Map.Entry<String, Object> attrEntry : attrEntries) {
String attributeName = attrEntry.getKey();
Object value = attrEntry.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, attrsResult.getRequest(), attributeName);
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
}
}
}
}
if (!data.isEmpty()) {
metricsService.addData(data);
if (LOG.isDebugEnabled()) {
LOG.debug("added " + data.size() + " metrics");
}
}
}
}
Aggregations