Unsolved

This post is more than 5 years old

2 Posts

1218

February 19th, 2013 06:00

Retrieving all entries in ICF_PersistentDataSet using invoke operation from Java

Hello All,

We are trying to get all the entries in a ICF_PersistentDataSet via invoke operation using Java API. But we are not able to find any relevant options or documentation.

We are able to get single entry by using getEntry . we are able to see all the entries from "dmctl -s invoke  ICF_PersistentDataSet:: get". We need a similar functionality from Java API.

Regards,

Ullas

170 Posts

February 19th, 2013 07:00

Hi Ullas,

Please find Remote API guide attached.

Please see the sample code in the GetEnets example.

This should help you get started with the above.

Kind Regards,

Paul O'Rourke

1 Attachment

2 Posts

February 25th, 2013 04:00

Hello Paul,

Thanks for the Guide.  What we are specifically looking at is the functionality to retrieve all the entries in a data set.

There is option to get the entries from DMCTL using dmctl -s invoke  ICF_PersistentDataSet:: get , which would get all the entries in the data set.

But there is only GetEntry which would get us only the specific key values pair. Is there ay way to get the entire data set entries via Java API?

Regards,

Ullas

February 26th, 2013 13:00

Hello Ullas,

From what I have read of your first post you are trying to get this information from the domain using the Java API.  If you wish to get this information from the domain manager using the java API then please refer to the GetEnets program that starts on page 43 of the PDF guide Paul attached.

This program example that is provided is an example program that uses the Java API to get all the interfaces of a router.  The section of code relating to getting all the interfaces of a router are on lines 57 to 89.  You can modify this code so that instead of getting all the instances of interfaces for the routers (i.e. all the instances of class interface that are on all the instances of class router) to instead get all the instances of ICF_PersistentDataSet.

In the example code on pages 44 through 47 you will need to modify the section starting at line 57 (listEthernets).  What you would ultimately be doing is modifying this code so that it looks for instance of only the ICF_PErsistentDataSet class.  Instead of instances of interfaces on the Routers.  The changes would need to be made starting at line 62 of this code, changing "Router" to  "ICF_PersistentDataSet" and then getting rid of all the extra code and function calls that were originally used to dig deeper into the Router class.

If I were to take a rough shot at the code I would do something like the following:

import java.io.*;

import java.net.UnknownHostException;

import java.util.*;

import com.smarts.repos.*;

import com.smarts.remote.*;

public class GetEnets

{

    public static void main(String[] argv) {

        String brokerName, domainName, userName, userPassword;

        if (argv.length != 4) {

            System.out.println("Usage: BrokerName DomainName UserName UserPassword");

            System.exit(-1);

        } else {

            brokerName = argv[0];

            domainName = argv[1];

            userName = argv[2];

            userPassword = argv[3];

            //

            // Run the process...

            //

            runProc(brokerName, domainName, userName, userPassword);

        }

    }

    public static void runProc(String brokerName, String domainName, String userName, String userPassword)

    {

        //

        // Connect to the domain manager.

        //

        SmRemoteDomainManager remoteDM = connectToDomain(brokerName, domainName, userName, userPassword);

        if (null == remoteDM) {

            System.out.println("Failed to get remote domain...");

            System.exit(-1);

        }

        //

        // If we're still here...

        //

        try {

            //

            // Run the process, then drop the connection with the domain.

            //

            listICF_PersistentDataSet(remoteDM);

            remoteDM.detach();

        } catch(Throwable t) {

            System.err.println("Client application fault: " + t.toString());

            System.exit (1);

        }

    }

    static public void listICF_PersistentDataSet(SmRemoteDomainManager remoteDM)

    {

        try {

            MR_Ref[] items = remoteDM.findInstances("ICF_PersistentDataSet", ".*", MR_Choice.EXPAND_SUBCLASSES);

            for(int i=0; i

                System.out.println("ICF_PersistentDataSet: " + items.getInstanceName());

            }

        } catch(Throwable t) {

            System.out.println("Failure running app: getEnets.class");

        }

    }

    static public SmRemoteDomainManager connectToDomain(String brokerName, String domainName, String userName, String userPassword)

    {

        SmRemoteDomainManager remoteDM = new SmRemoteDomainManager();

        try {

            //

            // Create InCharge Manager and Broker and attach to server

            //

            SmRemoteBroker broker = new SmRemoteBroker(brokerName);

            //

            // Attach to the broker with these credentials. Youmust attach to

            // the broker with credentials before attempting an attach to the

            // domain.

            //

            broker.attach("BrokerNonsecure", "Nonsecure");

            remoteDM.attach(broker, domainName, userName, userPassword);

            broker.detach();

            return (remoteDM);

        } catch (UnknownHostException uhe) {

            System.err.println("UnknownHostException: IP Address of host could not be determined. " + uhe);

            return (null);

        } catch (IOException ioe) {

            System.err.println("IOException: Failed or interrupted I/O operation. " + ioe);

            return (null);

        } catch (SmRemoteException sre) {

            System.err.println("SmRemoteException: Exception in a remote InCharge Manager. " + sre);

            return (null);

        }

    }

}

The parts in bold are where I made the changes to the original code.  I haven't taken the opportunity to compile and test this code, but it should give you a basic idea of what you are aiming for.  If you look at this code and compare it to the original you should see what has been changed and it should be very easy to understand why it has been changed.

If you want to use the dmctl command to get all the instances of the ICF_PersistentDataSet you would use the command:

dmctl -s getI ICF_PersistentDataSet

in the Smarts software versions 8.1.X and higher.

If this has answered your question satisfactorily then please update your original post and mark it to show that the question has been answered.  If you have any follow up questions please feel free to ask and we will try to answer them to the best of our abilities.

Thank you very much Ullas.

Cheers,

Sean

Sean Mackinnon | EMC ASD - Smarts |  Monday - Friday 8:30 - 16:30 EST/EDT | Hopkinton, MA, USA

No Events found!

Top