@Override public void start(Map<String,String> map){
  try {
    port=Integer.parseInt(map.get(MongodbSinkConnector.PORT));
  }
 catch (  Exception e) {
    throw new ConnectException("Setting " + MongodbSinkConnector.PORT + " should be an integer");
  }
  try {
    bulkSize=Integer.parseInt(map.get(MongodbSinkConnector.BULK_SIZE));
  }
 catch (  Exception e) {
    throw new ConnectException("Setting " + MongodbSinkConnector.BULK_SIZE + " should be an integer");
  }
  database=map.get(MongodbSinkConnector.DATABASE);
  host=map.get(MongodbSinkConnector.HOST);
  collections=map.get(MongodbSinkConnector.COLLECTIONS);
  topics=map.get(MongodbSinkConnector.TOPICS);
  List<String> collectionsList=Arrays.asList(collections.split(","));
  List<String> topicsList=Arrays.asList(topics.split(","));
  MongoClient mongoClient=new MongoClient(host,port);
  db=mongoClient.getDatabase(database);
  mapping=new HashMap<>();
  for (int i=0; i < topicsList.size(); i++) {
    String topic=topicsList.get(i);
    String collection=collectionsList.get(i);
    mapping.put(topic,db.getCollection(collection));
  }
}

@ Override public void start ( Map < String , String > map ) { try { port = Integer . parseInt ( map . get ( MongodbSinkConnector . PORT ) ) ; } catch ( Exception e ) { throw new ConnectException ( "Setting " + MongodbSinkConnector . PORT + " should be an integer" ) ; } try { bulkSize = Integer . parseInt ( map . get ( MongodbSinkConnector . BULK_SIZE ) ) ; } catch ( Exception e ) { throw new ConnectException ( "Setting " + MongodbSinkConnector . BULK_SIZE + " should be an integer" ) ; } database = map . get ( MongodbSinkConnector . DATABASE ) ; host = map . get ( MongodbSinkConnector . HOST ) ; collections = map . get ( MongodbSinkConnector . COLLECTIONS ) ; topics = map . get ( MongodbSinkConnector . TOPICS ) ; List < String > collectionsList = Arrays . asList ( collections . split ( "," ) ) ; List < String > topicsList = Arrays . asList ( topics . split ( "," ) ) ; MongoClient mongoClient = new MongoClient ( host , port ) ; db = mongoClient . getDatabase ( database ) ; mapping = new HashMap < > ( ) ; for ( int i = 0 ; i < topicsList . size ( ) ; i ++ ) { String topic = topicsList . get ( i ) ; String collection = collectionsList . get ( i ) ; mapping . put ( topic , db . getCollection ( collection ) ) ; } }
start the task . handles configuration parsing and one - time setup of the task .
