Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Disable HTTP server and LUS for unit tests

I have found the following settings in the "Moving into production check list - Space Configuration with Unit Tests".

<os-core:embedded-space id="space" name="myspace">
<os-core:properties>
    <props>
        <prop key="com.j_spaces.core.container.directory_services.jini_lus.start-embedded-lus">false</prop>
        <prop key="com.j_spaces.core.container.directory_services.jini_lus.enabled">false</prop>
        <prop key="com.j_spaces.core.container.directory_services.jndi.enabled">false</prop>
        <prop key="com.j_spaces.core.container.embedded-services.httpd.enabled">false</prop>
    </props>
</os-core:properties>

</os-core:embedded-space>

(Besides that this is maybe not the best place to put this info) I tried it with the embedded spaces we use in our unit tests but unfortunatly the settings did not work out es expected.
I tried the following to config once using "addProperty" and I also tried "addUrlProperty". (btw: whats the difference between those two??)C:\fakepath\TestOutputs.zip

UrlSpaceConfigurer cfg= new UrlSpaceConfigurer("/./" + repositoryName);
cfg.lookupGroups(env.getEnvironmentVariableOrDefault(ENV_LOOKUP_GROUPS, LOOKUP_GROUPS_DEFAULT));
cfg.addProperty("com.j_spaces.core.container.directory_services.jini_lus.start-embedded-lus", "false");
cfg.addProperty("com.j_spaces.core.container.directory_services.jini_lus.enabled", "false");
cfg.addProperty("com.j_spaces.core.container.directory_services.jndi.enabled", "false");
cfg.addProperty("com.j_spaces.core.container.embedded-services.httpd.enabled", "false");

The log outputs off both test runs (once using addProperty and once addUrlProperty) is included in the attached zip archive.

Here is a short review: When using "addProperty" it does not work in our tests: (Looks like a JMX issue)

2014-11-30 20:18:59,866 INFO [com.gigaspaces.core.common] - Starting Space [managementDomainlMlYwXY8Nm_container:managementDomainlMlYwXY8Nm] with url [/./managementDomainlMlYwXY8Nm?groups=XXX&schema=default&state=started] ... 2014-11-30 20:19:00,726 INFO [com.gigaspaces.cache] - Cache manager created with policy [ALL IN CACHE], persistency mode [memory] 2014-11-30 20:19:00,895 INFO [com.gigaspaces.core.common] - Space [managementDomainlMlYwXY8Nm_container:managementDomainlMlYwXY8Nm] with url [/./managementDomainlMlYwXY8Nm?groups=XXX&schema=default&state=started] started successfully 2014-11-30 20:19:02,094 WARNING [com.gigaspaces.jmx] - Failed to receive MBean Server.java.io.IOException: Cannot bind to URL [rmi://192.168.12.54:10098/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.12.54; nested exception is: java.net.ConnectException: Connection refused: connect]; Caused by: java.io.IOException: Cannot bind to URL [rmi://192.168.12.54:10098/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.12.54; nested exception is: java.net.ConnectException: Connection refused: connect]

asked 2014-12-01 05:22:39 -0600

leozilla gravatar image

updated 2014-12-01 05:24:39 -0600

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

jini:////<name>?groups=<locator groups="">

see the documentation here:

http://docs.gigaspaces.com/xap97/the-...

answered 2014-12-02 09:50:25 -0600

jb gravatar image
edit flag offensive delete link more
0

URL for creatingan embedded space and getting a proxy to it (“java” URL): –java://<localhost[:port]> .="" <space-name=""> –Or, the short version: /./<space-name> •Example: /./mySpace

answered 2014-12-02 09:43:33 -0600

Yuval gravatar image
edit flag offensive delete link more
0

Hi,

I have tested it and found that it is working when I comment this line: .addProperty("com.j_spaces.core.container.directory_services.jini_lus.enabled", "false") When the lus is disabled I'm getting another exception (ClosedChannelException). Try to enable the lus by comment this line. Did it work for you?

This is my test:

package com.gigaspaces;

import com.gigaspaces.annotation.pojo.SpaceClass; import com.gigaspaces.annotation.pojo.SpaceId; import com.gigaspaces.annotation.pojo.SpaceIndex; import com.gigaspaces.annotation.pojo.SpaceRouting; import com.gigaspaces.metadata.index.SpaceIndexType; import org.openspaces.core.GigaSpace; import org.openspaces.core.GigaSpaceConfigurer; import org.openspaces.core.space.UrlSpaceConfigurer;

/** * Created by Yuvald on 01-Dec-14. */ public class Main {

public static void main(String[] args) {

    GigaSpace gigaSpace = new GigaSpaceConfigurer(new UrlSpaceConfigurer("/./mySpace").lookupGroups("yuvald_101")
    .addProperty("com.j_spaces.core.container.directory_services.jini_lus.start-embedded-lus", "false")
    .addProperty("com.j_spaces.core.container.directory_services.jini_lus.enabled", "false")
    .addProperty("com.j_spaces.core.container.directory_services.jndi.enabled", "false")
    .addProperty("com.j_spaces.core.container.embedded-services.httpd.enabled", "false")
    .space()).gigaSpace();

    for (int i = 0; i < 10; i++){
        Car car = new Car();
        car.setModel("Mazda" + i);
        gigaSpace.write(car);
    }

    try {
        Thread.sleep(1000000);
    }catch(InterruptedException ex){
        ex.printStackTrace();
    }
}

@SpaceClass
public static class Car
{
    public String id;
    public String Model;
    public boolean isActive;

    @SpaceId(autoGenerate = true)
    @SpaceRouting()
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @SpaceIndex(type= SpaceIndexType.BASIC)
    public String getModel() {
        return Model;
    }

    public void setModel(String model) {
        this.Model = model;
    }

    @SpaceIndex
    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean isActive) {
        isActive = isActive;
    }
}

}

answered 2014-12-01 15:17:38 -0600

Yuval gravatar image
edit flag offensive delete link more

Comments

Thank you for your answer! Your solution works fine but now there is only one more problem: How do I configure the spaceUrl so that I can access the space from different threads?

Previously with the lus we were able to just configure the urls like this -> "jini:////" + actualSpaceName".

What URL do I need to use to connect to the space on the same machine?
I tried: "jini://localhost//" and "java://localhost//" so far.

Currently we use this code for creating the space proxy:

private void establishNewConnection() {
    IJSpace javaSpace = factory.create(spaceUrl);
    synchronized (sync) {
        space = new GigaSpaceConfigurer(javaSpace).clustered(true).transactionManager(txManager).gigaSpace();
        isConnected = true;
    }
}
leozilla gravatar imageleozilla ( 2014-12-02 03:02:00 -0600 )edit
0

You can create multiple embedded spaces within one process without an LUS, but you cannot connect to an embedded space from another process without an LUS.

answered 2014-12-09 11:20:28 -0600

jb gravatar image
edit flag offensive delete link more

Comments

Ok so when I start a JUnit test than there will only be one process and when I execute the code (UrlSpaceConfigurer) above twice, will this then create multiple embedded spaces within this same process?

leozilla gravatar imageleozilla ( 2014-12-10 02:16:12 -0600 )edit

public static void main(String[] args) {

    List<GigaSpace> spaces = new ArrayList<GigaSpace>();

    for (int i = 1; i <= 3; i++) {
        UrlSpaceConfigurer urlConfig = createUrlSpaceConfig("space" + i);
        GigaSpaceConfigurer spaceConfig = new GigaSpaceConfigurer(urlConfig);
        spaces.add(spaceConfig.create());
    }

    for (GigaSpace space : spaces) {
        System.out.println(space.getName());
    }

}


public static UrlSpaceConfigurer createUrlSpaceConfig(String repositoryName) {

    UrlSpaceConfigurer urlConfig = new UrlSpaceConfigurer("/./" + repositoryName);
    urlConfig.addProperty("com.j_spaces.core.container.directory_services.jini_lus.start-embedded-lus", "false");
    urlConfig.addProperty("com.j_spaces.core.container.directory_services.jini_lus.enabled", "false");
    urlConfig.addProperty("com.j_spaces.core.container.directory_services.jndi.enabled", "false");
    urlConfig.addProperty("com.j_spaces.core.container.embedded-services.httpd.enabled", "false");

    return urlConfig;
}

2014-12-10 10:49:35,974 WARNING [com.gigaspaces.jmx] - Failed to receive MBean Server.java.io.IOException: Cannot bind to URL [rmi://10.10.10.109:10098/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.10.10.109; nested exception is: java.net.ConnectException: Connection refused]; Caused by: java.io.IOException: Cannot bind to URL [rmi://10.10.10.109:10098/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.10.10.109; nested exception is: java.net.ConnectException: Connection refused] space1 space2 space3

jb gravatar imagejb ( 2014-12-10 10:22:43 -0600 )edit

Yes, as you can see above. The only issue remaining is to disable the MBean but I believe this is hardcoded.

jb gravatar imagejb ( 2014-12-10 10:24:24 -0600 )edit

-Dcom.gs.jmx.enabled=false

Will disable the MBean

2014-12-10 11:38:17,827 INFO [com.gigaspaces.container] - MBean Server did not start since the JMX support is disabled.

jb gravatar imagejb ( 2014-12-10 10:40:49 -0600 )edit

One of the differences between my code and yours is that i am using the DistributedJiniTxManager.

txManager = new DistributedJiniTxManagerConfigurer().transactionManager();    
new GigaSpaceConfigurer(configurer).transactionManager(txManager).create();

Do I need to use another TxManager? maybe the transaction isolation level is the cause why I do not see the writes..

leozilla gravatar imageleozilla ( 2014-12-12 05:46:13 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-12-01 05:22:39 -0600

Seen: 233 times

Last updated: Dec 09 '14