Search in sources :

Example 1 with TwillContext

use of org.apache.twill.api.TwillContext in project cdap by caskdata.

the class DistributedProgramRunnableModuleTest method createModule.

@Test
public void createModule() throws Exception {
    DistributedProgramRunnableModule distributedProgramRunnableModule = new DistributedProgramRunnableModule(CConfiguration.create(), new Configuration());
    Guice.createInjector(distributedProgramRunnableModule.createModule(new ProgramId("ns", "app", ProgramType.MAPREDUCE, "program"), RunIds.generate().getId(), "0", "user/host@KDC.NET"));
    Guice.createInjector(distributedProgramRunnableModule.createModule(new TwillContext() {

        @Override
        public RunId getRunId() {
            return null;
        }

        @Override
        public RunId getApplicationRunId() {
            return null;
        }

        @Override
        public int getInstanceCount() {
            return 0;
        }

        @Override
        public InetAddress getHost() {
            // used by DistributedProgramRunnableModule#createModule(TwillContext)
            return new InetSocketAddress("localhost", 0).getAddress();
        }

        @Override
        public String[] getArguments() {
            return new String[0];
        }

        @Override
        public String[] getApplicationArguments() {
            return new String[0];
        }

        @Override
        public TwillRunnableSpecification getSpecification() {
            return null;
        }

        @Override
        public int getInstanceId() {
            return 0;
        }

        @Override
        public int getVirtualCores() {
            return 0;
        }

        @Override
        public int getMaxMemoryMB() {
            return 0;
        }

        @Override
        public ServiceDiscovered discover(String name) {
            return null;
        }

        @Override
        public Cancellable electLeader(String name, ElectionHandler participantHandler) {
            return null;
        }

        @Override
        public Lock createLock(String name) {
            return null;
        }

        @Override
        public Cancellable announce(String serviceName, int port) {
            return null;
        }

        @Override
        public Cancellable announce(String serviceName, int port, byte[] payload) {
            return null;
        }
    }, new ProgramId("ns", "app", ProgramType.MAPREDUCE, "program"), RunIds.generate().getId(), "0", "user/host@KDC.NET"));
}
Also used : CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) ElectionHandler(org.apache.twill.api.ElectionHandler) ProgramId(co.cask.cdap.proto.id.ProgramId) TwillContext(org.apache.twill.api.TwillContext) Test(org.junit.Test)

Aggregations

CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 ProgramId (co.cask.cdap.proto.id.ProgramId)1 InetSocketAddress (java.net.InetSocketAddress)1 Configuration (org.apache.hadoop.conf.Configuration)1 ElectionHandler (org.apache.twill.api.ElectionHandler)1 TwillContext (org.apache.twill.api.TwillContext)1 Test (org.junit.Test)1