env.setStateBackend deprecated in 1.5 for FsStateBackend

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

env.setStateBackend deprecated in 1.5 for FsStateBackend

chrisr123

I upgraded from Flink 1.4 to 1.5 and now this call is being flagged as
deprecated.
What should I change this code to for 1.5 to get rid of the deprecation
warning?
Thanks

// deprecated
env.setStateBackend(new
FsStateBackend("hdfs://myhdfsmachine:9000/flink/checkpoints"));



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: env.setStateBackend deprecated in 1.5 for FsStateBackend

zhangminglei
At the moment, it seems you can not. Because FsStateBackend extends AbstructFileStateBackend then extend AbstructStateBackend which is deprecated in setStateBackend parameter.. I think you can do what you want like below now but it is very bad.
env.setStateBackend(new StateBackend() {
@Override
public CompletedCheckpointStorageLocation resolveCheckpoint(String externalPointer) throws IOException {
return null;
}

@Override
public CheckpointStorage createCheckpointStorage(JobID jobId) throws IOException {
return null;
}

@Override
public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend(Environment env, JobID jobID, String operatorIdentifier, TypeSerializer<K> keySerializer, int numberOfKeyGroups, KeyGroupRange keyGroupRange, TaskKvStateRegistry kvStateRegistry) throws Exception {
return null;
}

@Override
public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception {
return null;
}
});
Cheers
Minglei


在 2018年6月27日,上午9:38,chrisr123 <[hidden email]> 写道:


I upgraded from Flink 1.4 to 1.5 and now this call is being flagged as
deprecated.
What should I change this code to for 1.5 to get rid of the deprecation
warning?
Thanks

// deprecated
env.setStateBackend(new
FsStateBackend("<a href="hdfs://myhdfsmachine:9000/flink/checkpoints" class="">hdfs://myhdfsmachine:9000/flink/checkpoints"));



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: env.setStateBackend deprecated in 1.5 for FsStateBackend

Rong Rong
Hmm. 

If you have a wrapper function like this, it will not report deprecated warning. 
def getFsStateBackend(path: String): StateBackend = return new FsStateBackend(path) 

Since AbstractStateBackend implements StateBackend and 
def setStateBackend(backend: StateBackend): StreamExecutionEnvironment is not deprecated.

This seems like a bug to me though. 

--
Rong

On Tue, Jun 26, 2018 at 7:40 PM zhangminglei <[hidden email]> wrote:
At the moment, it seems you can not. Because FsStateBackend extends AbstructFileStateBackend then extend AbstructStateBackend which is deprecated in setStateBackend parameter.. I think you can do what you want like below now but it is very bad.
env.setStateBackend(new StateBackend() {
@Override
public CompletedCheckpointStorageLocation resolveCheckpoint(String externalPointer) throws IOException {
return null;
}

@Override
public CheckpointStorage createCheckpointStorage(JobID jobId) throws IOException {
return null;
}

@Override
public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend(Environment env, JobID jobID, String operatorIdentifier, TypeSerializer<K> keySerializer, int numberOfKeyGroups, KeyGroupRange keyGroupRange, TaskKvStateRegistry kvStateRegistry) throws Exception {
return null;
}

@Override
public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception {
return null;
}
});
Cheers
Minglei


在 2018年6月27日,上午9:38,chrisr123 <[hidden email]> 写道:


I upgraded from Flink 1.4 to 1.5 and now this call is being flagged as
deprecated.
What should I change this code to for 1.5 to get rid of the deprecation
warning?
Thanks

// deprecated
env.setStateBackend(new
FsStateBackend("hdfs://myhdfsmachine:9000/flink/checkpoints"));



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: env.setStateBackend deprecated in 1.5 for FsStateBackend

Fabian Hueske-2
Hi,

You can just add a cast to StateBackend to get rid of the deprecation warning:

env.setStateBackend((StateBackend) new
   FsStateBackend("hdfs://myhdfsmachine:9000/flink/checkpoints"));

Best, Fabian

2018-06-27 5:47 GMT+02:00 Rong Rong <[hidden email]>:
Hmm. 

If you have a wrapper function like this, it will not report deprecated warning. 
def getFsStateBackend(path: String): StateBackend = return new FsStateBackend(path) 

Since AbstractStateBackend implements StateBackend and 
def setStateBackend(backend: StateBackend): StreamExecutionEnvironment is not deprecated.

This seems like a bug to me though. 

--
Rong

On Tue, Jun 26, 2018 at 7:40 PM zhangminglei <[hidden email]> wrote:
At the moment, it seems you can not. Because FsStateBackend extends AbstructFileStateBackend then extend AbstructStateBackend which is deprecated in setStateBackend parameter.. I think you can do what you want like below now but it is very bad.
env.setStateBackend(new StateBackend() {
@Override
public CompletedCheckpointStorageLocation resolveCheckpoint(String externalPointer) throws IOException {
return null;
}

@Override
public CheckpointStorage createCheckpointStorage(JobID jobId) throws IOException {
return null;
}

@Override
public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend(Environment env, JobID jobID, String operatorIdentifier, TypeSerializer<K> keySerializer, int numberOfKeyGroups, KeyGroupRange keyGroupRange, TaskKvStateRegistry kvStateRegistry) throws Exception {
return null;
}

@Override
public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception {
return null;
}
});
Cheers
Minglei


在 2018年6月27日,上午9:38,chrisr123 <[hidden email]> 写道:


I upgraded from Flink 1.4 to 1.5 and now this call is being flagged as
deprecated.
What should I change this code to for 1.5 to get rid of the deprecation
warning?
Thanks

// deprecated
env.setStateBackend(new
FsStateBackend("hdfs://myhdfsmachine:9000/flink/checkpoints"));



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/