Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Routine


    }

    private void expectRoutines(String schemaName, String... routineNames) {
        final AkibanInformationSchema ais = ddl().getAIS(session());
        for (String name : routineNames) {
            final Routine routine = ais.getRoutine(schemaName, name);
            assertNotNull(schemaName + " " + name + " doesn't exist", routine);
        }
    }
View Full Code Here


    }

    private void expectNotRoutines(String schemaName, String... routineNames) {
        final AkibanInformationSchema ais = ddl().getAIS(session());
        for (String name : routineNames) {
            final Routine routine = ais.getRoutine(schemaName, name);
            assertNull(schemaName + " " + name + " still exists", routine);
        }
    }
View Full Code Here

    @Test
    public void userAndSystemRoutines() {
        final TableName sysName = new TableName(TableName.SYS_SCHEMA, "sys");
        final TableName userName = new TableName(SCHEMA, "user");
        AkibanInformationSchema temp = new AkibanInformationSchema();
        final Routine sysR = Routine.create(temp, sysName.getSchemaName(), sysName.getTableName(), "other", Routine.CallingConvention.SQL_ROW);
        final Routine userR = Routine.create(temp, userName.getSchemaName(), userName.getTableName(), "java", Routine.CallingConvention.JAVA);

        schemaManager.registerSystemRoutine(sysR);
        assertNotNull("Found sys routine after register", ais().getRoutine(sysName));

        transactionallyUnchecked(new Runnable() {
View Full Code Here

    }

    @Test
    public void testCreateJava() throws Exception {
        executeDDL("CREATE PROCEDURE proca(IN x INT, OUT d DOUBLE) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'ajar:com.acme.Procs.aproc'");
        Routine proc = ais().getRoutine(SCHEMA_NAME, "proca");
        assertNotNull(proc);
        assertEquals("java", proc.getLanguage());
        assertEquals(Routine.CallingConvention.JAVA, proc.getCallingConvention());
        assertEquals(2, proc.getParameters().size());
        assertEquals("x", proc.getParameters().get(0).getName());
        assertEquals(Parameter.Direction.IN, proc.getParameters().get(0).getDirection());
        assertEquals("INT", proc.getParameters().get(0).getTypeName());
        assertEquals("d", proc.getParameters().get(1).getName());
        assertEquals("DOUBLE", proc.getParameters().get(1).getTypeName());
        assertEquals(Parameter.Direction.OUT, proc.getParameters().get(1).getDirection());
        assertEquals(Routine.SQLAllowed.READS_SQL_DATA, proc.getSQLAllowed());
        assertEquals(1, proc.getDynamicResultSets());
    }
View Full Code Here

            .dynamicResultSets(2);
       
        AkibanInformationSchema inAIS = builder.ais();
        AkibanInformationSchema outAIS = writeAndRead(inAIS);

        Routine proc = outAIS.getRoutine(SCHEMA, "PROC1");
        assertNotNull(proc);
       
        SQLJJar jar = proc.getSQLJJar();
        assertNotNull(jar);
        assertEquals("myjar", jar.getName().getTableName());
        assertEquals("http://example.com/procs.jar", jar.getURL().toString());

        assertEquals("java", proc.getLanguage());
        assertEquals(Routine.CallingConvention.JAVA, proc.getCallingConvention());
        assertEquals(3, proc.getParameters().size());
        assertEquals("x1", proc.getParameters().get(0).getName());
        assertEquals(Parameter.Direction.IN, proc.getParameters().get(0).getDirection());
        assertEquals("BIGINT", proc.getParameters().get(0).getTypeName());
        assertEquals("x2", proc.getParameters().get(1).getName());
        assertEquals("BIGINT", proc.getParameters().get(1).getTypeName());
        assertEquals(Parameter.Direction.IN, proc.getParameters().get(1).getDirection());
        assertEquals("d", proc.getParameters().get(2).getName());
        assertEquals("DOUBLE", proc.getParameters().get(2).getTypeName());
        assertEquals(Parameter.Direction.OUT, proc.getParameters().get(2).getDirection());
        assertEquals("com.acme.Procs", proc.getClassName());
        assertEquals("proc1", proc.getMethodName());
        assertEquals(Routine.SQLAllowed.READS_SQL_DATA, proc.getSQLAllowed());
        assertEquals(2, proc.getDynamicResultSets());
    }
View Full Code Here

            .externalName("com.acme.Procs", "proc1");
       
        AkibanInformationSchema inAIS = builder.ais();
        AkibanInformationSchema outAIS = writeAndRead(inAIS);

        Routine proc = outAIS.getRoutine(SCHEMA, "PROC2");
       
        assertEquals("java", proc.getLanguage());
        assertEquals(Routine.CallingConvention.LOADABLE_PLAN, proc.getCallingConvention());
        assertEquals(0, proc.getParameters().size());
    }
View Full Code Here

    }

    @Override
    public LoadablePlan<?> loadLoadablePlan(Session session, TableName routineName) {
        AkibanInformationSchema ais = ais(session);
        Routine routine = ais.getRoutine(routineName);
        if (routine == null)
            throw new NoSuchRoutineException(routineName);
        if (routine.getCallingConvention() != Routine.CallingConvention.LOADABLE_PLAN)
            throw new SQLJInstanceException(routineName, "Routine was not loadable plan");
        long currentVersion = routine.getVersion();
        LoadablePlan<?> loadablePlan;
        synchronized (loadablePlans) {
            VersionedItem<LoadablePlan<?>> entry = loadablePlans.get(routineName);
            if ((entry != null) && (entry.version == currentVersion)) {
                loadablePlan = entry.item;
            }
            else {
                TableName jarName = null;
                if (routine.getSQLJJar() != null)
                    jarName = routine.getSQLJJar().getName();
                ClassLoader classLoader = loadSQLJJar(session, jarName);
                try {
                    loadablePlan = (LoadablePlan<?>)
                        Class.forName(routine.getClassName(), true, classLoader).newInstance();
                }
                catch (Exception ex) {
                    throw new SQLJInstanceException(routineName, ex);
                }
                if (entry != null) {
View Full Code Here

        return loadablePlan;
    }

    @Override
    public Method loadJavaMethod(Session session, TableName routineName) {
        Routine routine = ais(session).getRoutine(routineName);
        if (routine == null)
            throw new NoSuchRoutineException(routineName);
        if (routine.getCallingConvention() != Routine.CallingConvention.JAVA)
            throw new SQLJInstanceException(routineName, "Routine was not SQL/J");
        long currentVersion = routine.getVersion();
        synchronized (javaMethods) {
            VersionedItem<Method> entry = javaMethods.get(routineName);
            if ((entry != null) && (entry.version == currentVersion))
                return entry.item;
            TableName jarName = null;
            if (routine.getSQLJJar() != null)
                jarName = routine.getSQLJJar().getName();
            ClassLoader classLoader = loadSQLJJar(session, jarName);
            Class<?> clazz;
            try {
                clazz = Class.forName(routine.getClassName(), true, classLoader);
            }
            catch (Exception ex) {
                throw new SQLJInstanceException(routineName, ex);
            }
            String methodName = routine.getMethodName();
            String methodArgs = null;
            int idx = methodName.indexOf('(');
            if (idx >= 0) {
                methodArgs = methodName.substring(idx+1);
                methodName = methodName.substring(0, idx);
View Full Code Here

        return scripts.getScriptLibrary(session, routineName);
    }

    @Override
    public void checkUnloadRoutine(Session session, TableName routineName) {
        Routine routine = ais(session).getRoutine(routineName);
        long currentVersion = -1;
        if (routine != null)
            currentVersion = routine.getVersion();
        synchronized (loadablePlans) {
            VersionedItem<LoadablePlan<?>> entry = loadablePlans.remove(routineName);
            if ((entry != null) && (entry.version == currentVersion)) {
                loadablePlans.put(routineName, entry); // Was valid after all.
            }
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Routine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.