-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flink] Replace legacy SinkFunction with v2 Sink
- Loading branch information
1 parent
e72c06c
commit 980b08f
Showing
15 changed files
with
383 additions
and
49 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...imon-flink-1.15/src/main/java/org/apache/flink/api/connector/sink2/WriterInitContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.api.connector.sink2; | ||
|
||
/** Placeholder class to resolve compatibility issues. */ | ||
public interface WriterInitContext extends org.apache.flink.api.connector.sink2.Sink.InitContext {} |
58 changes: 58 additions & 0 deletions
58
...k-1.15/src/main/java/org/apache/flink/streaming/api/functions/sink/v2/DiscardingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.streaming.api.functions.sink.v2; | ||
|
||
import org.apache.flink.annotation.PublicEvolving; | ||
import org.apache.flink.api.connector.sink2.Sink; | ||
import org.apache.flink.api.connector.sink2.SinkWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A special sink that ignores all elements. | ||
* | ||
* @param <IN> The type of elements received by the sink. | ||
*/ | ||
@PublicEvolving | ||
public class DiscardingSink<IN> implements Sink<IN> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public SinkWriter<IN> createWriter(InitContext context) throws IOException { | ||
return new DiscardingElementWriter(); | ||
} | ||
|
||
private class DiscardingElementWriter implements SinkWriter<IN> { | ||
|
||
@Override | ||
public void write(IN element, Context context) throws IOException, InterruptedException { | ||
// discard it. | ||
} | ||
|
||
@Override | ||
public void flush(boolean endOfInput) throws IOException, InterruptedException { | ||
// this writer has no pending data. | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
// do nothing. | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...imon-flink-1.16/src/main/java/org/apache/flink/api/connector/sink2/WriterInitContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.api.connector.sink2; | ||
|
||
/** Placeholder class to resolve compatibility issues. */ | ||
public interface WriterInitContext extends org.apache.flink.api.connector.sink2.Sink.InitContext {} |
58 changes: 58 additions & 0 deletions
58
...k-1.16/src/main/java/org/apache/flink/streaming/api/functions/sink/v2/DiscardingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.streaming.api.functions.sink.v2; | ||
|
||
import org.apache.flink.annotation.PublicEvolving; | ||
import org.apache.flink.api.connector.sink2.Sink; | ||
import org.apache.flink.api.connector.sink2.SinkWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A special sink that ignores all elements. | ||
* | ||
* @param <IN> The type of elements received by the sink. | ||
*/ | ||
@PublicEvolving | ||
public class DiscardingSink<IN> implements Sink<IN> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public SinkWriter<IN> createWriter(InitContext context) throws IOException { | ||
return new DiscardingElementWriter(); | ||
} | ||
|
||
private class DiscardingElementWriter implements SinkWriter<IN> { | ||
|
||
@Override | ||
public void write(IN element, Context context) throws IOException, InterruptedException { | ||
// discard it. | ||
} | ||
|
||
@Override | ||
public void flush(boolean endOfInput) throws IOException, InterruptedException { | ||
// this writer has no pending data. | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
// do nothing. | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...imon-flink-1.17/src/main/java/org/apache/flink/api/connector/sink2/WriterInitContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.api.connector.sink2; | ||
|
||
import org.apache.flink.annotation.Public; | ||
|
||
/** Placeholder class to resolve compatibility issues. */ | ||
@Public | ||
public interface WriterInitContext extends org.apache.flink.api.connector.sink2.Sink.InitContext {} |
59 changes: 59 additions & 0 deletions
59
...k-1.17/src/main/java/org/apache/flink/streaming/api/functions/sink/v2/DiscardingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.streaming.api.functions.sink.v2; | ||
|
||
import org.apache.flink.annotation.PublicEvolving; | ||
import org.apache.flink.api.common.SupportsConcurrentExecutionAttempts; | ||
import org.apache.flink.api.connector.sink2.Sink; | ||
import org.apache.flink.api.connector.sink2.SinkWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A special sink that ignores all elements. | ||
* | ||
* @param <IN> The type of elements received by the sink. | ||
*/ | ||
@PublicEvolving | ||
public class DiscardingSink<IN> implements Sink<IN>, SupportsConcurrentExecutionAttempts { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public SinkWriter<IN> createWriter(InitContext context) throws IOException { | ||
return new DiscardingElementWriter(); | ||
} | ||
|
||
private class DiscardingElementWriter implements SinkWriter<IN> { | ||
|
||
@Override | ||
public void write(IN element, Context context) throws IOException, InterruptedException { | ||
// discard it. | ||
} | ||
|
||
@Override | ||
public void flush(boolean endOfInput) throws IOException, InterruptedException { | ||
// this writer has no pending data. | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
// do nothing. | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...imon-flink-1.18/src/main/java/org/apache/flink/api/connector/sink2/WriterInitContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.api.connector.sink2; | ||
|
||
/** Placeholder class to resolve compatibility issues. */ | ||
public interface WriterInitContext extends org.apache.flink.api.connector.sink2.Sink.InitContext {} |
59 changes: 59 additions & 0 deletions
59
...k-1.18/src/main/java/org/apache/flink/streaming/api/functions/sink/v2/DiscardingSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.streaming.api.functions.sink.v2; | ||
|
||
import org.apache.flink.annotation.PublicEvolving; | ||
import org.apache.flink.api.common.SupportsConcurrentExecutionAttempts; | ||
import org.apache.flink.api.connector.sink2.Sink; | ||
import org.apache.flink.api.connector.sink2.SinkWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A special sink that ignores all elements. | ||
* | ||
* @param <IN> The type of elements received by the sink. | ||
*/ | ||
@PublicEvolving | ||
public class DiscardingSink<IN> implements Sink<IN>, SupportsConcurrentExecutionAttempts { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public SinkWriter<IN> createWriter(InitContext context) throws IOException { | ||
return new DiscardingElementWriter(); | ||
} | ||
|
||
private class DiscardingElementWriter implements SinkWriter<IN> { | ||
|
||
@Override | ||
public void write(IN element, Context context) throws IOException, InterruptedException { | ||
// discard it. | ||
} | ||
|
||
@Override | ||
public void flush(boolean endOfInput) throws IOException, InterruptedException { | ||
// this writer has no pending data. | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
// do nothing. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.