@Override public String getPath(Distribution distribution) { String downloadPath = distribution.getVersion().asInDownloadPath(); BitSize bs = distribution.getBitsize(); switch (distribution.getPlatform()) { case OS_X: return format("%s-x86%s.tar.gz", downloadPath, bs == B32 ? "" : "_64"); case Linux: return format("%s-%s.tar.gz", downloadPath, bs == B32 ? "i686" : "x86_64"); case Windows: return format("%s-win%s.zip", downloadPath, bs == B32 ? "32" : "x64"); default: throw new RuntimeException("Not implemented for: " + distribution.getPlatform()); } } }
protected boolean withSsl(Distribution distribution) { if ((distribution.getPlatform() == Platform.Windows || distribution.getPlatform() == Platform.OS_X) && distribution.getVersion() instanceof IFeatureAwareVersion) { return ((IFeatureAwareVersion) distribution.getVersion()).enabled(Feature.ONLY_WITH_SSL); } else { return false; } }
@Override public String getPath(Distribution distribution) { if (distribution.getPlatform()==Platform.Windows) { return "https://downloads.mongodb.org/"; } return "https://fastdl.mongodb.org/"; }
try { int pid = getPidFromFile(pidFile); Platform platform = Distribution.detectFor(version) .getPlatform(); synchronized (MemcachedProcess.class) { logger.info("try to stop memcached");
private static boolean isFeatureEnabled(Distribution distribution, Feature feature) { return (distribution.getVersion() instanceof IFeatureAwareVersion && ((IFeatureAwareVersion) distribution.getVersion()).enabled(feature)); }
public EXECUTABLE prepare(CONFIG config) { return prepare(config, Distribution.detectFor(config.version())); }
public static Distribution detectFor(IVersion version) { return new Distribution(version, Platform.detect(), BitSize.detect()); }
@Override public ArchiveType getArchiveType(Distribution distribution) { ArchiveType archiveType; switch (distribution.getPlatform()) { case Linux: case OS_X: archiveType = ArchiveType.TGZ; break; case Windows: archiveType = ArchiveType.ZIP; break; default: throw new IllegalArgumentException("Unknown Platform " + distribution.getPlatform()); } return archiveType; }
@Override public FileSet getFileSet(Distribution distribution) { return com.wix.mysql.distribution.FileSet.emit( distribution.getPlatform(), (Version) distribution.getVersion()); }
@Override protected final void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); // memcached prints all status messages on error console, and only // if // started with -vv LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor( "server listening", knownFailureMessages(), StreamToLineProcessor.wrap(outputConfig.getError())); Processors.connect(process.getError(), logWatch); logWatch.waitForResult(getConfig().timeout().getStartupTimeout()); if (!logWatch.isInitWithSuccess()) { throw new IOException("Could not start process:" + logWatch.getOutput()); } if (Distribution.detectFor(getConfig().version()).getPlatform() == Platform.Windows) { // On windows, process won't be writing a pid file. Sigh. Use // some // force to find out the pid anyways. This works pretty well // on Unix // (won't help us much here..) and needs Sigar lib on Windows. setProcessId(process.getPid()); } else { setProcessId(getPidFromFile(pidFile())); } }
protected boolean useWindows2008PlusVersion(Distribution distribution) { String osName = System.getProperty("os.name"); if (osName.contains("Windows Server 2008 R2") || (distribution.getVersion() instanceof IFeatureAwareVersion) && ((IFeatureAwareVersion) distribution.getVersion()).enabled(Feature.ONLY_WINDOWS_2008_SERVER)) { return true; } else { return osName.contains("Windows 7"); } }
public EXECUTABLE prepare(CONFIG config) throws DistributionException{ return prepare(config, Distribution.detectFor(config.version())); }
private String getBitSize(Distribution distribution) { String sbitSize; switch (distribution.getBitsize()) { case B32: if (distribution.getVersion() instanceof IFeatureAwareVersion) { IFeatureAwareVersion featuredVersion = (IFeatureAwareVersion) distribution.getVersion(); if (featuredVersion.enabled(Feature.ONLY_64BIT)) { throw new IllegalArgumentException("this version does not support 32Bit: "+distribution); switch (distribution.getPlatform()) { case Linux: sbitSize = "i686"; break; default: throw new IllegalArgumentException("Platform " + distribution.getPlatform() + " not supported yet on 32Bit Platform"); break; default: throw new IllegalArgumentException("Unknown BitSize " + distribution.getBitsize());
@Override public ArchiveType getArchiveType(Distribution distribution) { ArchiveType archiveType; switch (distribution.getPlatform()) { case Linux: archiveType = ArchiveType.TGZ; break; case OS_X: case Windows: archiveType = ArchiveType.ZIP; break; default: throw new IllegalArgumentException("Unknown Platform " + distribution.getPlatform()); } return archiveType; }
@Override public String getPath(Distribution distribution) { String sversion = getVersionPart(distribution.getVersion()); switch (distribution.getPlatform()) { case Linux: splatform = "linux"; default: throw new IllegalArgumentException("Unknown Platform " + distribution.getPlatform());
public PostgresFilesToExtract(IDirectory dirFactory, ITempNaming executableNaming, FileSet fileSet, Distribution distribution) { super(dirFactory, executableNaming, fileSet); this.fileSet = fileSet; if (dirFactory.asFile() != null) { final File file = new File(dirFactory.asFile(), "pgsql-" + distribution.getVersion().asInDownloadPath()); if (!file.exists()) { //noinspection ResultOfMethodCallIgnored file.mkdir(); } this.extractBasePath = file.getPath(); } else { this.extractBasePath = null; } }
public static void startMongoDB() throws IOException { if (!started.compareAndSet(false, true)) { throw new RuntimeException("Embedded mongo already running, call stopMongoDB before starting it again!"); } final String bindIp = "localhost"; try { final int port = Network.getFreeServerPort(); final IMongodConfig mongodConfig = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(bindIp, port, Network.localhostIsIPv6())) .build(); final MongodStarter runtime = MongodStarter.getInstance(new RuntimeConfigBuilder() .defaultsWithLogger(Command.MongoD, LOG) .build()); mongodExecutable = runtime.prepare(mongodConfig, Distribution.detectFor(Version.Main.PRODUCTION)); mongodProcess = mongodExecutable.start(); mongoClient = new MongoClient(bindIp, port); } catch (final IOException e) { stopMongoDB(); throw e; } }
static String asPath(Distribution distribution) { return new StringBuilder() .append(distribution.getPlatform().name()) .append("-") .append(distribution.getBitsize().name()) .append("--") .append(distribution.getVersion().asInDownloadPath()) .toString(); }
@Override public List<String> getLibrary(Distribution distribution) { return _libraries.get(distribution.getPlatform()); }
@Override public IExtractedFileSet extractFileSet(Distribution distribution) throws IOException { try { final File dir = this.eDir.asFile(); final FileSet filesSet = downloadConfig.getPackageResolver().getFileSet(distribution); final Path path = get(dir.getPath(), "pgsql" + "-" + distribution.getVersion().asInDownloadPath(), "pgsql"); if (exists(path)) { final Builder extracted = builder(dir).baseDirIsGenerated(false); iterateFiles(path.toFile(), TRUE, TRUE).forEachRemaining(file -> { FileType type = Library; if (filesSet.entries().stream() .anyMatch(entry -> entry.matchingPattern().matcher(file.getPath()).matches())) { type = Executable; } extracted.file(type, file); }); return extracted.build(); } else { return super.extractFileSet(distribution); } } catch (Exception e) { LOGGER.error("Failed to extract file set", e); return new EmptyFileSet(); } } }