Version 2

    This article is out-of-date. See the project docs for later versions.


    Admin API is programmatic Java API that is defined to configure, monitor and manage runtime of resources in Teiid's deployment environment. All the external tools like JOPR console plugin and AdminShell use Admin API underneath and provide GUI or script based support to aid the user in managing the resources in Teiid.

     

    Using Admin API, user can

    • Deploy VDB
    • Define a Connector
    • Query for available sessions
    • Terminate a transaction
    • Change a property in the system
    • etc..

     

    For complete list check out the javadoc for "org.teiid.adminapi" package and its "Admin" class. User can obtain a handle to "admin" interface on the Teiid's JDBC connection class.

        public class Teiid {
            public Admin getAdmin(String user, String password) throws Exception {
                String url = "jdbc:teiid:admin@mm://localhost:31000;ApplicationName=myApp";
                Class.forName("org.teiid.jdbc.TeiidDriver");
                Connection c = (com.metamatrix.jdbc.api.Connection)DriverManager.getConnection(url, user, password);
                return c.getAdminAPI();
            }
        }


    The above code fragment looks exactly like making any JDBC connection to a VDB, except for couple differences

    1. The code is connecting to a special VDB called "Admin.vdb", which comes with Teiid install. However, it is not mandatory that you use this VDB. You can connect to any deployed VDB and grab the Admin connection off that connection.
    2. The connection is type casted to "com.metamatrix.jdbc.api.Connection" class, which is custom extension to the "java.sql.Connection" class. Then you can call "getAdminAPI()" call on this interface to get a handle to the Admin API.

     

    Now using this object you can call any method available on this interface provided you have right authorizations to call such methods. See Managing User Authorizations in Teiid for granting such authorizations. For example to add a VDB, you can call as

     

    byte[] vdbStream = ...
    Admin admin = getAdmin("admin", "teiid");
    admin.addVDB("myVDB", vdbStream, AdminOptions.OnConflict.EXCEPTION);
    

     

    Note: If you are grabbing your Teiid JDBC connection from a connection pool, these connections may be wrapped with a proxy class. Type casting such a connection class to "com.metamatrix.jdbc.api.Connection" will produce a ClassCastException. In such cases you need to correctly unwrap the proxy connection and get to the right connection object before you can type cast it to the "com.metamatrix.jdbc.api.Connection" interface. We also planning on providing monitoring using JMX, however it currently not defined on the road map. If you are interested using JMX with Teiid or contributing please let us know.