I think you want to embed a locator in the same process as your server,
you'll need to use the start-locator property Kirk mentioned earlier and
not use the LocatorLauncher.

new ServerLauncher.Builder()
                .setServerBindAddress("localhost")
                .setServerPort(9900)
                .set("locators", "localhost[7300]")
                .set("start-locator", "localhost[7300]")
                .build()
                .start();

On Thu, Apr 21, 2016 at 10:24 AM, Eugene Strokin <[email protected]>
wrote:

> John, thanks for the info.
> You are correct, I'm running the Locator and Server from the same process.
> The code I've shown before in my previous email, but here is the gist for
> better readability:
> https://gist.github.com/strokine/1dd575d219c2d90edb91695de829eb45
>
>
> Thanks
> Eugene
>
>
> On Thu, Apr 21, 2016 at 12:45 PM, John Blum <[email protected]> wrote:
>
>> Eugene-
>>
>> Somewhere you have 2 instances of the GemFire DistributedSystem being
>> created in your application when you start the (peer) Cache.  This is
>> evident from the GemFire System properties shown below.  You will notice
>> (DistributedSystem) properties such as the following...
>>
>> ...
>> cache-xml-file="" ****(wanted "cache.xml")****
>> jmx-manager="true" ****(wanted "false")****
>> locators="10.36.76.221[9300]" ****(wanted "localhost[9300]")****
>> ...
>>
>> As you can see, when GemFire went to create an instance of your Cache...
>>
>>
>>
>> *at
>> com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.validateSameProperties(InternalDistributedSystem.java:2890)at
>> com.gemstone.gemfire.distributed.DistributedSystem.connect(DistributedSystem.java:1628)at
>> com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:224)*
>> at com.gemstone.gemfire.distributed.ServerLauncher.startWithGemFireApi(
>> ServerLauncher.java:822)
>> at com.gemstone.gemfire.distributed.ServerLauncher.
>> start(ServerLauncher.java:718)
>>
>> It detected
>> <https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java#L1606-1607>
>>  [0]
>> an "*existing*" instance of the DistributedSystem (for reasons that are
>> yet unknown).  As such, GemFire attempts to verify
>> <https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java#L1627-1629>
>>  [1]
>> that the properties are the same.  If not, it throws this error since the 2
>> instances maybe incompatible, not knowing what the users true intentions
>> were (i.e. take nothing for granted and fail fast).
>>
>> So why is there an existing DistributedSystem when you try to create an
>> instance of the Cache (which, will create a DistributedSystem
>> <https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CacheFactory.java#L218-L224>
>>  [2]
>> for you)?
>>
>> Are you using the ServerLauncher API programmatically?
>>
>> If so, how?  (Perhaps you could demonstrate and reproduce this problem
>> with a small example POJO or test).
>>
>> It is not common for an existing DistributedSystem to already exist.
>> Either a user explicitly creates one unnecessarily, or uses some flawed API
>> that created one implicitly, but unnecessarily.
>>
>> 1 recent example was a bug I fixed in the Spring Data GemFire API, that
>> attempted to create a Pool before creating the ClientCache.  However, in
>> order to create a Pool, you needed to have a DistributedSystem, so SDG
>> would create 1 prematurely that would later have to be reconciled in the
>> ClientCacheFactory when creating an instance of the ClientCache, which, of
>> course, would create an instance of the DistributedSystem.  A mess to be
>> sure.  See SGF-414 <https://jira.spring.io/browse/SGF-414> [3] and
>> SGF-416 <https://jira.spring.io/browse/SGF-416> [4] for more details.  I
>> cleaned this up and fixed this in SDG 1.8.
>>
>> Anyway, please help us by providing and example of what you are trying to
>> do.
>>
>> Thanks,
>> John
>>
>>
>> [0]
>> https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java#L1606-1607
>> [1]
>> https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java#L1627-1629
>> [2]
>> https://github.com/apache/incubator-geode/blob/rel/v1.0.0-incubating.M1/gemfire-core/src/main/java/com/gemstone/gemfire/cache/CacheFactory.java#L218-L224
>> [3] https://jira.spring.io/browse/SGF-414
>> [4] https://jira.spring.io/browse/SGF-453
>>
>>
>> On Thu, Apr 21, 2016 at 8:04 AM, Eugene Strokin <[email protected]>
>> wrote:
>>
>>> Actually, same problem for the Cache:
>>>
>>> Properties properties = new Properties();
>>> properties.setProperty("locators", LOCATORS.get());
>>> Cache cache = new CacheFactory(properties).create();
>>>
>>> As soon as I add locators, create() throws the same exception.
>>>
>>> On Thu, Apr 21, 2016 at 9:53 AM, Eugene Strokin <[email protected]>
>>> wrote:
>>>
>>>> Thanks Kirk,
>>>> I've tried your code. Which was very similar to what I have:
>>>>
>>>> new LocatorLauncher.Builder()
>>>> .setBindAddress(TRANSPORT_IP.get())
>>>> .setPort(LOCATOR_PORT.get())
>>>> .setWorkingDirectory("/opt/ccio/geode/locator")
>>>> .build()
>>>> .start();
>>>>
>>>> new ServerLauncher.Builder()
>>>> .setServerBindAddress(TRANSPORT_IP.get())
>>>> .setServerPort(TRANSPORT_PORT.get())
>>>> .setWorkingDirectory("/opt/ccio/geode/server")
>>>> .build()
>>>> .start();
>>>>
>>>> So, all I was missing is
>>>> .set("locators", LOCATORS.get())
>>>> for Server Launcher.
>>>> But as soon as I've added it, I've started getting exception:
>>>>
>>>> Exception in thread "main" java.lang.IllegalStateException: A
>>>> connection to a distributed system already exists in this VM.  It has the
>>>> following configuration:
>>>>   ack-severe-alert-threshold="0"
>>>>   ack-wait-threshold="15"
>>>>   archive-disk-space-limit="0"
>>>>   archive-file-size-limit="0"
>>>>   async-distribution-timeout="0"
>>>>   async-max-queue-size="8"
>>>>   async-queue-timeout="60000"
>>>>   bind-address=""
>>>>   cache-xml-file="" ***(wanted "cache.xml")***
>>>>   cluster-configuration-dir="/Users/es/git/ccio/ccio-image"
>>>>   cluster-ssl-ciphers="any"
>>>>   cluster-ssl-enabled="false"
>>>>   cluster-ssl-keystore=""
>>>>   cluster-ssl-keystore-password=""
>>>>   cluster-ssl-keystore-type=""
>>>>   cluster-ssl-protocols="any"
>>>>   cluster-ssl-require-authentication="true"
>>>>   cluster-ssl-truststore=""
>>>>   cluster-ssl-truststore-password=""
>>>>   conflate-events="server"
>>>>   conserve-sockets="true"
>>>>   delta-propagation="true"
>>>>   deploy-working-dir="."
>>>>   disable-auto-reconnect="false"
>>>>   disable-tcp="false"
>>>>   distributed-system-id="-1"
>>>>   distributed-transactions="false"
>>>>   durable-client-id=""
>>>>   durable-client-timeout="300"
>>>>   enable-cluster-configuration="true"
>>>>   enable-network-partition-detection="false"
>>>>   enable-time-statistics="false"
>>>>   enforce-unique-host="false"
>>>>   gateway-ssl-ciphers="any"
>>>>   gateway-ssl-enabled="false"
>>>>   gateway-ssl-keystore=""
>>>>   gateway-ssl-keystore-password=""
>>>>   gateway-ssl-keystore-type=""
>>>>   gateway-ssl-protocols="any"
>>>>   gateway-ssl-require-authentication="true"
>>>>   gateway-ssl-truststore=""
>>>>   gateway-ssl-truststore-password=""
>>>>   groups=""
>>>>   http-service-bind-address=""
>>>>   http-service-port="7070"
>>>>   http-service-ssl-ciphers="any"
>>>>   http-service-ssl-enabled="false"
>>>>   http-service-ssl-keystore=""
>>>>   http-service-ssl-keystore-password=""
>>>>   http-service-ssl-keystore-type=""
>>>>   http-service-ssl-protocols="any"
>>>>   http-service-ssl-require-authentication="false"
>>>>   http-service-ssl-truststore=""
>>>>   http-service-ssl-truststore-password=""
>>>>   jmx-manager="true" ***(wanted "false")***
>>>>   jmx-manager-access-file=""
>>>>   jmx-manager-bind-address=""
>>>>   jmx-manager-hostname-for-clients=""
>>>>   jmx-manager-http-port="7070"
>>>>   jmx-manager-password-file=""
>>>>   jmx-manager-port="1099"
>>>>   jmx-manager-ssl="false"
>>>>   jmx-manager-ssl-ciphers="any"
>>>>   jmx-manager-ssl-enabled="false"
>>>>   jmx-manager-ssl-keystore=""
>>>>   jmx-manager-ssl-keystore-password=""
>>>>   jmx-manager-ssl-keystore-type=""
>>>>   jmx-manager-ssl-protocols="any"
>>>>   jmx-manager-ssl-require-authentication="true"
>>>>   jmx-manager-ssl-truststore=""
>>>>   jmx-manager-ssl-truststore-password=""
>>>>   jmx-manager-start="false"
>>>>   jmx-manager-update-rate="2000"
>>>>   load-cluster-configuration-from-dir="false"
>>>>   locator-wait-time="0"
>>>>   locators="10.36.76.221[9300]" ***(wanted "localhost[9300]")***
>>>>   lock-memory="false"
>>>>   log-disk-space-limit="50"
>>>>   log-file="/opt/ccio/geode/logs/geode.log"
>>>>   log-file-size-limit="10"
>>>>   log-level="config"
>>>>   max-num-reconnect-tries="3"
>>>>   max-wait-time-reconnect="60000"
>>>>   mcast-address="/239.192.81.1"
>>>>   mcast-flow-control="1048576, 0.25, 5000"
>>>>   mcast-port="0"
>>>>   mcast-recv-buffer-size="1048576"
>>>>   mcast-send-buffer-size="65535"
>>>>   mcast-ttl="32"
>>>>   member-timeout="5000"
>>>>   membership-port-range="[1024,65535]"
>>>>   memcached-bind-address=""
>>>>   memcached-port="0"
>>>>   memcached-protocol="ASCII"
>>>>   name=""
>>>>   off-heap-memory-size=""
>>>>   redis-bind-address=""
>>>>   redis-password=""
>>>>   redis-port="0"
>>>>   redundancy-zone=""
>>>>   remote-locators=""
>>>>   remove-unresponsive-client="false"
>>>>   roles=""
>>>>   security-=""
>>>>   security-client-accessor=""
>>>>   security-client-accessor-pp=""
>>>>   security-client-auth-init=""
>>>>   security-client-authenticator=""
>>>>   security-client-dhalgo=""
>>>>   security-log-file=""
>>>>   security-log-level="config"
>>>>   security-peer-auth-init=""
>>>>   security-peer-authenticator=""
>>>>   security-peer-verifymember-timeout="1000"
>>>>   server-bind-address=""
>>>>   server-ssl-ciphers="any"
>>>>   server-ssl-enabled="false"
>>>>   server-ssl-keystore=""
>>>>   server-ssl-keystore-password=""
>>>>   server-ssl-keystore-type=""
>>>>   server-ssl-protocols="any"
>>>>   server-ssl-require-authentication="true"
>>>>   server-ssl-truststore=""
>>>>   server-ssl-truststore-password=""
>>>>   socket-buffer-size="32768"
>>>>   socket-lease-time="60000"
>>>>   ssl-ciphers="any"
>>>>   ssl-enabled="false"
>>>>   ssl-protocols="any"
>>>>   ssl-require-authentication="true"
>>>>   start-dev-rest-api="false"
>>>>   start-locator=""
>>>>   statistic-archive-file=""
>>>>   statistic-sample-rate="1000"
>>>>   statistic-sampling-enabled="true"
>>>>   tcp-port="0"
>>>>   udp-fragment-size="60000"
>>>>   udp-recv-buffer-size="1048576"
>>>>   udp-send-buffer-size="65535"
>>>>   use-cluster-configuration="true"
>>>>   user-command-packages=""
>>>> at
>>>> com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.validateSameProperties(InternalDistributedSystem.java:2890)
>>>> at
>>>> com.gemstone.gemfire.distributed.DistributedSystem.connect(DistributedSystem.java:1628)
>>>> at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:224)
>>>> at
>>>> com.gemstone.gemfire.distributed.ServerLauncher.startWithGemFireApi(ServerLauncher.java:822)
>>>> at
>>>> com.gemstone.gemfire.distributed.ServerLauncher.start(ServerLauncher.java:718)
>>>> at ccio.image.ImageServer.main(ImageServer.java:80)
>>>>
>>>> This exception happens on start of the ServerLauncher.
>>>> And without "locators" property it worked.
>>>> Do you have any idea why this could be?
>>>>
>>>> Thanks,
>>>> Eugene
>>>>
>>>> On Wed, Apr 20, 2016 at 7:10 PM, Kirk Lund <[email protected]> wrote:
>>>>
>>>>> Hi Eugene,
>>>>>
>>>>> You can run a server and a locator on the same machine or even in the
>>>>> same process.
>>>>>
>>>>> Distributed system properties (see javadocs on DistributedSystem [1]):
>>>>> locators -- use this to specify one or more locators
>>>>> start-locator -- use this to embed a locator in a server process
>>>>>
>>>>> Launcher APIs:
>>>>> LocatorLauncher.Builder.set(String, String) and
>>>>> ServerLauncher.Builder.set(String, String) can be used to set any
>>>>> distributed system properties:
>>>>> new ServerLauncher.Builder().setMemberName("myname").set("locators",
>>>>> value).build().start();
>>>>>
>>>>> System Properties:
>>>>> Simply prepend any distributed system property with "gemfire." and it
>>>>> can be specified via a system property.
>>>>> a) Java API: System.setProperty("gemfire.locators", value);
>>>>> b) Java command-line: -Dgemfire.locators=value
>>>>> c) gfsh start command: --J-Dgemfire.locators=value
>>>>>
>>>>> CacheFactory API:
>>>>> Properties properties = new Properties();
>>>>> properties.set("locators", value);
>>>>> Cache cache = new CacheFactory(properties).create();
>>>>>
>>>>> The banner (first section) of the Geode log file will show how each
>>>>> distributed system property was specified (ie, the source of the values)
>>>>> for the Geode process.
>>>>>
>>>>> (I'm not sure if there are online geode javadocs or not so the
>>>>> following are gemfire 8.1 javadocs)
>>>>>
>>>>> [0]
>>>>> http://data-docs-samples.cfapps.io/docs-gemfire/latest/javadocs/japi/index.html
>>>>> [1]
>>>>> http://data-docs-samples.cfapps.io/docs-gemfire/latest/javadocs/japi/com/gemstone/gemfire/distributed/DistributedSystem.html
>>>>>
>>>>> -Kirk
>>>>>
>>>>>
>>>>> On Wed, Apr 20, 2016 at 1:24 PM, Eugene Strokin <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> It looks like DigitalOcean does not support Multicast IP.
>>>>>> In this case, from what I understood, I should be running Locators.
>>>>>> My idea was to start a server and a locator on the same node using
>>>>>> API (ServerLauncher, LocatorLauncher).
>>>>>> My assumption, that the server will read a list of locators from
>>>>>> gemfire.properties file and register itself there.
>>>>>> If this is correct, my only question is: Can I specify the list of
>>>>>> locators via API as well? Or maybe as a system property?
>>>>>> If I'm wrong about servers registering themselves using the list of
>>>>>> locators, please point me to the right direction.
>>>>>>
>>>>>> Thanks,
>>>>>> Eugene
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> -John
>> 503-504-8657
>> john.blum10101 (skype)
>>
>
>

Reply via email to