FabricServiceManager.getFabricLocatorInstance()
FabricServiceManager.getFabricServerInstance()
1. Add the following to your maven POM file to ensure the correct libraries are present.
<dependency> <groupId>com.pivotal.gemfirexd</groupId> <artifactId>gemfirexd</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>com.pivotal.gemfirexd</groupId> <artifactId>gemfirexd-client</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> <version>8.0.14</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-logging-juli</artifactId> <version>8.0.14</version> </dependency>
2. Create a start locator class as follows
package pivotal.au.gemfirexd.demos.startup; import com.pivotal.gemfirexd.FabricLocator; import com.pivotal.gemfirexd.FabricServiceManager; import java.sql.SQLException; import java.util.Properties; /** * Created by papicella on 4/11/2014. */ public class StartLocator1 { public static void main(String[] args) throws SQLException, InterruptedException { // TODO Auto-generated method stub Properties serverProps = new Properties(); serverProps.setProperty("sys-disk-dir","./gfxd/locator1"); serverProps.setProperty("server-bind-address","localhost"); serverProps.setProperty("jmx-manager-start","true"); serverProps.setProperty("jmx-manager-http-port","7075"); serverProps.setProperty("jmx-manager-bind-address","localhost"); FabricLocator locator = FabricServiceManager.getFabricLocatorInstance(); locator.start("localhost", 41111, serverProps); locator.startNetworkServer("127.0.0.1", 1527, null); System.out.println("Locator started ... "); Object lock = new Object(); synchronized (lock) { while (true) { lock.wait(); } } } }
3. Edit the run configuration to ensure you specify the GEMFIREXD ENV variable as shown below.
Note: This is needed to ensure Pulse can start when the locator starts
4. Create a start server class as follows.
package pivotal.au.gemfirexd.demos.startup; import com.pivotal.gemfirexd.FabricServer; import com.pivotal.gemfirexd.FabricServiceManager; import java.sql.SQLException; import java.util.Properties; public class StartServer1 { public static void main(String[] args) throws SQLException, InterruptedException { // TODO Auto-generated method stub FabricServer server = FabricServiceManager.getFabricServerInstance(); Properties serverProps = new Properties(); serverProps.setProperty("server-groups", "mygroup"); serverProps.setProperty("persist-dd", "false"); serverProps.setProperty("sys-disk-dir","./gfxd/server1"); serverProps.setProperty("host-data","true"); serverProps.setProperty("locators", "localhost[41111]"); server.start(serverProps); server.startNetworkServer("127.0.0.1", 1528, null); Object lock = new Object(); synchronized (lock) { while (true) { lock.wait(); } } } }
5. Start the locator by running "StartLocator1" class.
6. Start one server by running "StartServer1" class.
7. Connect to pulse to verify you have a 2 node distributed system with one locator and one member.
Using URL: http://localhost:7075/pulse/Login.html
No comments:
Post a Comment