У меня большой файл документа (~ 1,5 ГБ ~ 430 000 строк). Программа построчно читает файл документа и вставляет каждую строку в rethinkdb. Но я получаю эту ошибку между 11000-12000 строк. В чем причина?
java.lang.OutOfMemoryError: невозможно создать новый собственный поток в
java.lang.Thread.start0 (собственный метод) ~ [na: 1.8.0_171] at
java.lang.Thread.start (Thread.java:717) ~ [na: 1.8.0_171] at
java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:957)
~ [na: 1.8.0_171] в
java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1367)
~ [na: 1.8.0_171] в
java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:112)
~ [na: 1.8.0_171] в
java.util.concurrent.Executors $ DelegatedExecutorService.submit (Executors.java:678)
~ [na: 1.8.0_171] в
com.rethinkdb.net.Connection.connect (Connection.java:105)
~ [rethinkdb-driver-2.3.3.jar: na] в
com.rethinkdb.net.Connection.reconnect (Connection.java:94)
~ [rethinkdb-driver-2.3.3.jar: na] в
com.rethinkdb.net.Connection.reconnect (Connection.java:83)
~ [rethinkdb-driver-2.3.3.jar: na] в
com.rethinkdb.net.Connection $ Builder.connect (Connection.java:422)
~ [rethinkdb-driver-2.3.3.jar: na] в
com.erdem.rethinkdb.inserter.config.RethinkDBConnectionFactory.createConnection (RethinkDBConnectionFactory.java:17)
~ [классы /: нет] в
com.erdem.rethinkdb.inserter.service.InserterService.insertData (InserterService.java:33)
~ [классы /: нет] в
com.erdem.rethinkdb.inserter.service.InserterService.insertData (InserterService.java:38)
~ [классы /: нет] в
com.erdem.rethinkdb.inserter.InserterApplication.batchInsert (InserterApplication.java:168)
[классы /: на] в
com.erdem.rethinkdb.inserter.InserterApplication.fileModeIndex (InserterApplication.java:97)
[классы /: на] в
com.erdem.rethinkdb.inserter.InserterApplication.run (InserterApplication.java:57)
[классы /: на] в
org.springframework.boot.SpringApplication.callRunner (SpringApplication.java:788)
[spring-boot-2.0.2.RELEASE.jar: 2.0.2.RELEASE] в
org.springframework.boot.SpringApplication.callRunners (SpringApplication.java:778)
[spring-boot-2.0.2.RELEASE.jar: 2.0.2.RELEASE] в
org.springframework.boot.SpringApplication.run (SpringApplication.java:335)
[spring-boot-2.0.2.RELEASE.jar: 2.0.2.RELEASE] в
org.springframework.boot.SpringApplication.run (SpringApplication.java:1255)
[spring-boot-2.0.2.RELEASE.jar: 2.0.2.RELEASE] в
org.springframework.boot.SpringApplication.run (SpringApplication.java:1243)
[spring-boot-2.0.2.RELEASE.jar: 2.0.2.RELEASE] в
com.erdem.rethinkdb.inserter.InserterApplication.main (InserterApplication.java:37)
[Классы /: на]
RethinkDBConnectionFactory.java
public class RethinkDBConnectionFactory {
private final RethinkDB r = RethinkDB.r;
private String host;
public RethinkDBConnectionFactory(String host) {
this.host = host;
}
public Connection createConnection() {
return r.connection().hostname(host).connect();
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
}
InserterService
@Service
public class InserterService {
protected final Logger log = LoggerFactory.getLogger(InserterService.class);
private final RethinkDB r = RethinkDB.r;
@Autowired
private RethinkDBConnectionFactory connectionFactory;
private ObjectMapper oMapper = new ObjectMapper();
@SuppressWarnings("unchecked")
public void insertData(Activity activity) {
oMapper.setSerializationInclusion(Include.NON_NULL);
Map<Object, Object> map = oMapper.convertValue(activity, Map.class);
r.db("test").table("twitter").insert(map).run(connectionFactory.createConnection());
}
}
RethinkDBConfiguration
@Configuration
@ComponentScan(basePackages = { "com.erdem.rethinkdb.inserter.*" })
@PropertySource("classpath:application.yml")
public class RethinkDBConfiguration {
@Value("${rethinkdb.host}")
private String DBHOST;
@Bean
public RethinkDBConnectionFactory connectionFactory() {
return new RethinkDBConnectionFactory(DBHOST);
}
@Bean
public DbInitializer dbInitializer() {
return new DbInitializer();
}
}