public HillviewServer(final HostAndPort listenAddress, final IDataSet initialDataset) throws IOException { this.initialDatasets = new HashMap<Integer, IDataSet>(); this.addInitialDataset(initialDataset); this.listenAddress = listenAddress; this.memoizedCommands = new MemoizedResults(); this.server = NettyServerBuilder.forAddress(new InetSocketAddress(listenAddress.getHost(), listenAddress.getPort())) .executor(executorService) .workerEventLoopGroup(workerElg) .bossEventLoopGroup(bossElg) .addService(this) .maxInboundMessageSize(MAX_MESSAGE_SIZE) .build() .start(); this.dataSets = CacheBuilder.newBuilder() .expireAfterAccess(EXPIRE_TIME_IN_HOURS, TimeUnit.HOURS) .removalListener( (RemovalListener<Integer, IDataSet>) removalNotification -> HillviewLogger.instance.info("Removing reference to dataset", "{0}: {1}", removalNotification.getKey(), removalNotification.getValue().toString())) .build(); this.toUnsubscribe = CacheBuilder.newBuilder() .expireAfterAccess(EXPIRE_TIME_IN_HOURS, TimeUnit.HOURS) .build(); }
/** {@inheritDoc} */ @Override public Server build() { if (!CheckGcpEnvironment.isOnGcp()) { if (enableUntrustedAlts) { logger.log( Level.WARNING, "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the " + "ALTS handshaker service"); } else { Status status = Status.INTERNAL.withDescription("ALTS is only allowed to run on Google Cloud Platform"); delegate.intercept(new FailingServerInterceptor(status)); } } delegate.protocolNegotiator( AltsProtocolNegotiator.createServerNegotiator( new TsiHandshakerFactory() { @Override public TsiHandshaker newHandshaker(String authority) { // Used the shared grpc channel to connecting to the ALTS handshaker service. // TODO: Release the channel if it is not used. // https://github.com/grpc/grpc-java/issues/4755. return AltsTsiHandshaker.newServer( HandshakerServiceGrpc.newStub(handshakerChannelPool.getObject()), new AltsHandshakerOptions(RpcProtocolVersionsUtil.getRpcProtocolVersions())); } })); return delegate.build(); }
return serverBuilder.build();
return serverBuilder.build();