The first call to mesos, needed to setup connection properly and identify
a framework.

@throws URISyntaxException if the URL provided was not a syntactically correct URL.
504681
public void subscribe(URI mesosMasterURI, SingularityMesosScheduler scheduler) throws URISyntaxException {

    FrameworkInfo frameworkInfo = buildFrameworkInfo();

    if (mesosMasterURI == null || mesosMasterURI.getScheme().contains("zk")) {
      throw new IllegalArgumentException(String.format("Must use master address for http api (e.g. http://localhost:5050/api/v1/scheduler) was %s", mesosMasterURI));
    }

    if (openStream == null || openStream.isUnsubscribed()) {

      // Do we get here ever?
      if (subscriberThread != null) {
        subscriberThread.interrupt();
      }

      subscriberThread = new Thread() {
        public void run() {
          try {
            connect(mesosMasterURI, frameworkInfo, scheduler);
          } catch (RuntimeException|URISyntaxException e) {
            LOG.error("Could not connect: ", e);
            scheduler.onConnectException(e);
          }
        }

      };
      subscriberThread.start();
    }
  }
344188
public URI toURI() throws URISyntaxException {
        return new URI(_scheme, null, _host, _port, _path, _query == null ? null : UrlEncoded.decodeString(_query), _fragment);
    }
1267292
@CheckReturnValue
  static URI createUri(String scheme, InetAddress address, int port) throws URISyntaxException {
    checkNotNull(address);
    return new URI(
        scheme,
        null /* userInfo */,
        InetAddresses.toUriString(address),
        port,
        null /* path */,
        null /* query */,
        null /* fragment */);
  }
686024
@Override
  public void initialize(HttpRequest httpRequest) throws IOException {
    // Do not throw if execute fails, since Axis will handle unmarshalling the
    // fault.
    httpRequest.setThrowExceptionOnExecuteError(false);

    // For consistency with the default Axis HTTPSender and CommonsHTTPSender, do not
    // follow redirects.
    httpRequest.setFollowRedirects(false);

    // Retry should be handled by the client.
    httpRequest.setNumberOfRetries(0);
  }
240329
protected void setupInitialRegistryPaths() throws IOException {
        if (registryOperations instanceof RMRegistryOperationsService) {
            RMRegistryOperationsService rmRegOperations =
                    (RMRegistryOperationsService) registryOperations;
            rmRegOperations.initUserRegistryAsync(jstormMasterContext.service_user_name);
        }
    }
691594
@VisibleForTesting
    protected Mesos startInternal() {
        String version = System.getenv("MESOS_API_VERSION");
        if (version == null) {
            version = "V0";
        }

        LOGGER.info("Using Mesos API version: {}", version);

        if (version.equals("V0")) {
            if (credential == null) {
                return new V0Mesos(this, frameworkInfo, master);
            } else {
                return new V0Mesos(this, frameworkInfo, master, credential);
            }
        } else if (version.equals("V1")) {
            if (credential == null) {
                return new V1Mesos(this, master);
            } else {
                return new V1Mesos(this, master, credential);
            }
        } else {
            throw new IllegalArgumentException("Unsupported API version: " + version);
        }
    }
1008971
public URI rewriteURI(RequestContext rc) throws URISyntaxException {
        Request request = rc.request();
        String path = request.path();
        if (!path.startsWith(prefix)) {
            return null;
        }

        return computeDestinationURI(request, path, proxyTo, prefix);
    }
544198
public void setURI(URI uri) throws URIException {

        if (uri.getScheme() == null || uri.getScheme().equals("")) {
            mUri = new URI(HTTP + "://" + getHeader(HOST) + "/" + mUri.toString(), true);
            
        } else {
            mUri = uri;
        }

        if (uri.getScheme().equalsIgnoreCase(HTTPS)) {
            mIsSecure = true;
            
        } else {
            mIsSecure = false;
        }

        setHostPort(mUri.getPort());
    }
991558
@Override
    public boolean acceptsURL(String url) throws SQLException {

        if(url.startsWith(sqldroidPrefix) || url.startsWith(xerialPrefix)) {
            return true;
        }

        return false;
    }
1252483
public void initialize(URI name, Configuration conf) throws IOException {
    // if an underlying fs has not already been specified,
    // create and initialize one
    if (this.fs == null) {
      Class<?> clazz = conf.getClass("fs.apitrace.underlyingfs.impl",
                                     DistributedFileSystem.class);
      if (clazz == null) {
        throw new IOException("No FileSystem for fs.apitrace.underlyingfs.impl.");
      }

      this.fs = (FileSystem)ReflectionUtils.newInstance(clazz, null);
      super.initialize(name, conf);
    }

    // trace conf options
    for (String opt : traceConfOpts) {
      APITrace.CallEvent ce = new APITrace.CallEvent();
      ce.logCall(APITrace.COMMENT_msg, null,
                 new Object[] {opt, conf.get(opt, "")});
    }
  }
73796
@POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @RequiresPermissions(I18nPermissions.LOCALE_WRITE)
    public Response addAvailableLocale(LocaleRepresentation representation,
            @Context UriInfo uriInfo) throws URISyntaxException {
        WebAssertions.assertNotNull(representation, LOCALE_SHOULD_NOT_BE_BLANK);

        Locale result;
        if (!localeRepository.contains(representation.getCode())) {
            result = factory.createFromCode(representation.getCode());
            localeRepository.add(result);
        } else {
            return Response.status(Response.Status.CONFLICT).build();
        }

        return Response.created(new URI(uriInfo.getRequestUri() + "/" + result.getId()))
                .entity(localeFinder.findAvailableLocale(result.getId())).build();
    }
897753
private URI resolveExtSubsetPath(String systemId) throws IOException
    {
        // Do we have a context to use for resolving?
        URL ctxt = (mInput == null) ? null : mInput.getSource();

        /* Ok, either got a context or not; let's create the URL based on
         * the id, and optional context:
         */
        if (ctxt == null) {
            /* Call will try to figure out if system id has the protocol
             * in it; if not, create a relative file, if it does, try to
             * resolve it.
             */
            return URLUtil.uriFromSystemId(systemId);
        }
        URL url = URLUtil.urlFromSystemId(systemId, ctxt);
        try {
            return new URI(url.toExternalForm());
        } catch (URISyntaxException e) { // should never occur...
            throw new IOException("Failed to construct URI for external subset, URL = "+url.toExternalForm()+": "+e.getMessage());
        }
    }
300161
@Override
	protected void initialize() throws ResourceManagerException {
		// create and start the worker store
		try {
			this.workerStore = mesosServices.createMesosWorkerStore(flinkConfig, getRpcService().getExecutor());
			workerStore.start();
		} catch (Exception e) {
			throw new ResourceManagerException("Unable to initialize the worker store.", e);
		}

		// Prepare to register with Mesos
		Protos.FrameworkInfo.Builder frameworkInfo = mesosConfig.frameworkInfo()
			.clone()
			.setCheckpoint(true);
		if (webUiUrl != null) {
			frameworkInfo.setWebuiUrl(webUiUrl);
		}

		try {
			Option<Protos.FrameworkID> frameworkID = workerStore.getFrameworkID();
			if (frameworkID.isEmpty()) {
				LOG.info("Registering as new framework.");
			} else {
				LOG.info("Recovery scenario: re-registering using framework ID {}.", frameworkID.get().getValue());
				frameworkInfo.setId(frameworkID.get());
			}
		} catch (Exception e) {
			throw new ResourceManagerException("Unable to recover the framework ID.", e);
		}

		initializedMesosConfig = mesosConfig.withFrameworkInfo(frameworkInfo);
		MesosConfiguration.logMesosConfig(LOG, initializedMesosConfig);

		this.selfActor = createSelfActor();

		// configure the artifact server to serve the TM container artifacts
		try {
			LaunchableMesosWorker.configureArtifactServer(artifactServer, taskManagerContainerSpec);
		}
		catch (IOException e) {
			throw new ResourceManagerException("Unable to configure the artifact server with TaskManager artifacts.", e);
		}
	}
380755
public void init() throws UnavailableException
    {
        ServletContext config = getServletContext();
        _servletHandler = ((ServletHandler.Context) config).getServletHandler();
        _httpContext = _servletHandler.getHttpContext();

        _acceptRanges = getInitBoolean("acceptRanges");
        _dirAllowed = getInitBoolean("dirAllowed");
        _putAllowed = getInitBoolean("putAllowed");
        _delAllowed = getInitBoolean("delAllowed");
        _redirectWelcomeFiles = getInitBoolean("redirectWelcome");
        _minGzipLength = getInitInt("minGzipLength");

        String rrb = getInitParameter("relativeResourceBase");
        if (rrb != null)
        {
            try
            {
                _resourceBase = _httpContext.getBaseResource().addPath(rrb);
            }
            catch (Exception e)
            {
                log.warn(LogSupport.EXCEPTION, e);
                throw new UnavailableException(e.toString());
            }
        }

        String rb = getInitParameter("resourceBase");

        if (rrb != null && rb != null)
            throw new UnavailableException("resourceBase & relativeResourceBase");

        if (rb != null)
        {
            try
            {
                _resourceBase = Resource.newResource(rb);
            }
            catch (Exception e)
            {
                log.warn(LogSupport.EXCEPTION, e);
                throw new UnavailableException(e.toString());
            }
        }
        if (log.isDebugEnabled())
            log.debug("resource base = " + _resourceBase);

        if (_putAllowed)
            _AllowString += ", PUT";
        if (_delAllowed)
            _AllowString += ", DELETE";
        if (_putAllowed && _delAllowed)
            _AllowString += ", MOVE";
    }
465872
public final synchronized void initialize(Map<String,String> configuration)
    {
        if(this.initialized)
        {
            throw new FaxException("Request parser already initialized.");
        }
        
        //set flag
        this.initialized=true;
        
        //initialize
        this.initializeImpl(configuration);
    }
1165178
@Override
    public URI rewriteURI(RequestContext rc) throws URISyntaxException {
        Request request = rc.request();
        BalancerMember member = selectBalancerMember(rc);
        logger.debug("Selected {}", member.getName());
        String path = request.path();
        if (!path.startsWith(prefix)) {
            return null;
        }

        return computeDestinationURI(
                request,
                path,
                member.proxyTo(),
                prefix
        );
    }
1270086
private void init() throws IOException {
    Map<String, Integer> minDays = null;
    Map<String, Integer> firstDays = null;

    loadPatches();
    
    List<Path> resources = Utils.listResources(FILES);
    sanityCheck(resources);
    for (Path path : resources) {
      String fileName = path.getFileName().toString();
      if (!fileName.endsWith(".json")) {
        continue;
      }

      JsonObject root = load(path);
      switch (fileName) {

        case "aliases.json":
        {
          parseTimeZoneAliases(root);
          parseLanguageAliases(root);
          parseTerritoryAliases(root);
          break;
        }
        
        case "availableLocales.json":
          JsonObject locales = resolve(root, "availableLocales");
          for (JsonElement elem : locales.getAsJsonArray("modern")) {
            availableLocales.add(elem.getAsString());
          }
          break;

        case "ca-gregorian.json":
        {
          String code = localeCode(root);
          LocaleID id = parseIdentity(code, root);
          root = resolve(root, "main", code);
          DateTimeData data = parseCalendar(root);
          data.id = id;
          calendars.put(id, data);
          break;
        }

        case "currencies.json":
        {
          String code = localeCode(root);
          LocaleID id = parseIdentity(code, root);
          root = resolve(root, "main", code);
          parseCurrencyData(id, code, root);
          break;
        }

        case "currencyData.json":
          parseSupplementalCurrencyData(root);
          break;

        case "defaultContent.json":
          parseDefaultContent(root);
          break;
          
        case "languageMatching-fix.json":
        {
          parseLanguageMatchingFix(root);
          break;
        }
        
        case "likelySubtags.json":
          parseLikelySubtags(root);
          break;

        case "metaZones.json":
        {
          parseMetaZones(root);
          break;
        }
          
        case "numbers.json":
        {
          String code = localeCode(root);
          root = patch(fileName, code, root);
          LocaleID id = parseIdentity(code, root);
          root = resolve(root, "main", code);
          parseNumberData(id, code, root);
          break;
        }

        case "ordinals.json":
          parsePlurals(root, "plurals-type-ordinal", ordinals);
          break;

        case "plurals.json":
          parsePlurals(root, "plurals-type-cardinal", cardinals);
          break;

        case "territoryContainment.json":
        {
          parseTerritoryContainment(root);
          break;
        }
          
        case "timeZoneNames.json":
        {
          String code = localeCode(root);
          LocaleID id = parseIdentity(code, root);
          TimeZoneData data = parseTimeZoneData(code, root);
          timezones.put(id, data);
          break;
        }
        
        case "units.json":
        {
          String code = localeCode(root);
          LocaleID id = parseIdentity(code, root);
          UnitData data = parseUnitData(code, root);
          units.put(id, data);
          break;
        }
        
        case "weekData.json":
          minDays = parseMinDays(root);
          firstDays = parseFirstDays(root);
          break;
      }
    }
    
    Integer defaultFirstDay = firstDays.get("001");
    Integer defaultMinDays = minDays.get("001");

    for (Map.Entry<LocaleID, DateTimeData> entry : calendars.entrySet()) {
      String territory = entry.getKey().territory;
      DateTimeData data = entry.getValue();

      Integer value = minDays.getOrDefault(territory, defaultMinDays);
      data.minDays = value;

      value = firstDays.getOrDefault(territory, defaultFirstDay);
      data.firstDay = value - 1;
    }
  }