Skip to content

Latest commit

 

History

History
213 lines (136 loc) · 9.09 KB

local-configuration.md

File metadata and controls

213 lines (136 loc) · 9.09 KB

Running the API Mediation Layer on Local Machine

The API mediation layer can run on a z/OS system or your local machine (Mac/Linux/Windows).

To start each server individually with default settings for running on your local machine, run the following statements.

The default settings for running on local machine are stored in directory /config/local/.

Gateway Service

java -jar gateway-service/build/libs/gateway-service.jar --spring.config.additional-location=file:./config/local/gateway-service.yml

HTTPS

By default, the gateway runs in encrypted mode (HTTPS) for northbound traffic using signed certificates in Java keystore.

To override this and run the gateway without TLS encryption, add the following two arguments:

-Denvironment.scheme=http -Denvironment.sslEnabled=false

The source code contains sample certificates that are used by configuration for testing on your local machine. Do not use these certificates in other environments. More details can be found at /keystore/README.md.

Discovery Service

Note: If you want to run the discovery service using IntelliJ Run Dashboard, you need to add https in the Active profiles field in Edit Configuration.

java -jar discovery-service/build/libs/discovery-service.jar --spring.config.additional-location=file:./config/local/discovery-service.yml

API Catalog

java -jar api-catalog-services/build/libs/api-catalog-services.jar --spring.config.additional-location=file:./config/local/api-catalog-service.yml

Sample Application - Discoverable Client

java -jar discoverable-client/build/libs/discoverable-client.jar --spring.config.additional-location=file:./config/local/discoverable-client.yml

Sample Application - integration-enabler-spring-v1-sample-app

java -jar integration-enabler-spring-v1-sample-app/build/libs/enabler-springboot-1.5.9.RELEASE-sample.jar --spring.config.location=file:./config/local/integration-enabler-spring-v1-sample-app.yml

Sample Application - onboarding-enabler-java-sample-app

To run onboarding-enabler-java-sample-app, follow the steps below:

  1. Run ../gradlew tomcatRun from the onboarding-enabler-java-sample-app project directory Optional : You can override the keystore and truststore location with these additional parameters: -Djavax.net.ssl.trustStore="{your-project-directory}\api-layer\keystore\localhost\localhost.truststore.p12" -Djavax.net.ssl.trustStorePassword="password". If you need debug information about SSL configuration while deploying, use this parameter -Djavax.net.debug=SSL.

  2. Navigate to https://localhost:10011 and check if the service ENABLERJAVASAMPLEAPP is registered to the discovery service. You should be able to reach the following endpoints using HTTPS:

    Go to the API Catalog and check if the API documentation of the service is retrieved.

Default Discovery Timing Settings

Default timings can require up to 3 minutes for service startup discovery and shutdown to be registered. To change this settings so services register/de-register quicker, then append the following to the existing arguments

These settings are for development purposes only, it may result in false positive or unexpected behaviour.

-Deureka.instance.leaseExpirationDurationInSeconds=6 
-Deureka.instance.leaseRenewalIntervalInSeconds=5 
-Deureka.client.registryFetchIntervalSeconds=5 
-Deureka.client.initialInstanceInfoReplicationIntervalSeconds=5

Default API Catalog Refresh/Cache update Timing Settings (UI only)

Increase the service cache frequency rate which updates the Catalog UI with discovered service statuses.

These settings are for development purposes only, it may result in false positive or unexpected behaviour.

-Dapiml.service-registry.serviceFetchDelayInMillis=10000 
-Dapiml.service-registry.cacheRefreshUpdateThresholdInMillis=10000 
-Dapiml.service-registry.cacheRefreshInitialDelayInMillis=10000 
-Dapiml.service-registry.cacheRefreshRetryDelayInMillis=10000

Debugging

To turn on debugging messages for Zowe and informational messages for third-party dependencies:

--spring.profiles.active=dev

To turn on SSL/TLS protocol debugging:

-Djavax.net.debug=ssl:handshake 

IntelliJ Idea setup

If your editor of choice happens to be Idea and you want to use its 'Run Dashboard' refer to Setup your Idea.

Running multiple instances of Eureka locally

To run multiple instances of Eureka from your local environment follow these steps:

  1. Open the hosts file located inside C:\Windows\System32\drivers\etc directory as Administrator and add one or more virtual ip – hostname entries to allow discovery peers on your laptop.

    Example:

        127.0.0.2       localhost1
        127.0.0.3       localhost2
    
    • On Mac, this can be done by editing /etc/hosts file as the root:

        sudo nano /etc/hosts
      

      Add:

        127.0.0.2 localhost2
        127.0.0.3 localhost3
      

      Activate:

        dscacheutil -flushcache; sudo killall -HUP mDNSResponder
      

      Add virtual local network adapter on Mac:

        sudo ifconfig lo0 alias 127.0.0.2
        sudo ifconfig lo0 alias 127.0.0.3
      

      It can be removed issuing: ifconfig lo0 -alias 127.0.0.2

  2. Modify the discovery-service.yml and change the values of discoveryLocations, hostname, ipAddress and port as in the example below:

    Example:

    environment:
        cacheRefreshDelayInMillis: 10000
        discoveryLocations: http://eureka:password@discoveryInstance1:10022/eureka,http://eureka:password@discoveryInstance2:10033/eureka
        dsIpAddress: 0.0.0.0
        eurekaPassword: password
        eurekaUserId: eureka
        hostname: discoveryInstance1
        initialCacheRefreshDelayInMillis: 10000
        ipAddress: 127.0.0.2
        port: 10022
        preferIpAddress: false
        registryServiceInitialDelayInSeconds: 10
        registryServiceRetryDelayInSeconds: 5
        truststore: keystore/local/localhost_truststore.jks
        truststorePassword: trustword
        truststoreType: JKS
        updateThresholdInMillis: 10000
    
    spring:
        output:
            ansi:
                enabled: always
  3. Run the DiscoveryServiceApplication and once it's up, modify the .yml file again changing hostname, ipAddress and port with the values chosen for the other peer.

    • Without IntelliJ IDEA, you can run npm run api-layer-multi to run all the services from JARs. This task starts two discovery services with other API Mediation Layer services using configuration file in config/local-multi.
  4. Run DiscoveryServiceApplication again.

  5. Go to 127.0.0.x:yyyyy check the multiple instances registered with each other. If this was successful, the registered-replicas and available-replicas fields will contain the URL(s) of the other instance(s) of Eureka that you've created in the previous steps.

Note: This configuration will work when the preferIpAddress parameter is set to false. If you set it to true, you need to modify the value of discoveryLocations: to use IP address instead of hostname, otherwise Eureka won't be able to find the services registered and as consequence the available-replicas will be empty.

Example:

discoveryLocations: http://eureka:[email protected]:10022/eureka,http://eureka:[email protected]:10033/eureka

instead of

discoveryLocations: http://eureka:password@discoveryInstance1:10022/eureka,http://eureka:password@discoveryInstance2:10033/eureka

Ports Used

This is a list of default ports used by the project for developing

SERVICE PORT
Gateway 10010
Discovery Service 10011
Discoverable client 10012
API Catalog 10014
EnablerJavaSampleApp 10016