The filter is defined with the store meta data. A filter that is defined in the store will be applied at the locations. Since locations are added to stores, this data then propagates. The file size of a checked in file will represent the number of bytes streamed in from the client when the file was checked in. It is important to remember that in the filter implementation, the read must be the exact inverse transformation of the write; i.e. reading via the filter a file, which has been written on the disk via the filter, must return the original file. During the execution of the filter, the network layer is waiting for data, so an inefficient filter may cause network issues such as timeout or disconnection. These constraints have to be taken into account when implementing FCS filters. FCS server code cannot be considered responsible for issues caused by inefficient or bugged FCS filters. Filters which modify file content such as compression filters should not be added on a non-empty store since it may be difficult to manage in the filter implementation the fact that some files have been written through the filter and some have not. Filters which modify file content should not be removed on a non-empty store since it will not be possible to read the data in most cases due to an invalid read file size. The FCSStreamFilter is the Java interface that must be implemented and deployed on the FCS Server. The filter implementation needs to return the streams that are requested. Package com.matrixone.fcs.fcs; import java.io.InputStream; import java.io.OutputStream; import com.matrixone.fcs.common.FcsException; import com.matrixone.jdom.Element; public interface FCSStreamFilter { /** * Called when the fcs is doing a checkout. * The implementation needs to use the underlying stream to get the actual data * * @param fName - file name - hash name * @param info = the location info. * @param item - the item data structure * @param underlyingStream - an opened stream to the underlying data * @return modified stream * @throws Exception */ public InputStream getCheckoutStream(Item item,LocationInfo info,FcsContext context,InputStream underlyingStream) throws Exception; /** * Called when the fcs is doing a checkin. The implementation can either act as an end point or a filter. * The implementation needs to use the underlying stream to get the actual data * * @param item * @param info * @param context * @param underlyingStream * @return * @throws FcsException */ public OutputStream getCheckinStream(Item item, LocationInfo info, FcsContext context,OutputStream underlyingStream) throws FcsException; /** * Called with params for the location, if any. The params * @param params Root of the filter params */ public void init(Element params); } Deprecation notice Deprecation of the
The deprecation of
If you want to use file stream filters, you must no longer implement
the
The interface declaration has to change to the following: package com.matrixone.fcs.fcs; import java.io.InputStream; import java.io.OutputStream; import com.matrixone.fcs.common.FcsException; public interface FCSStreamFilter { /** * Called when the fcs is doing a checkout. * The implementation needs to use the underlying stream to get the actual data * * @param context * @param info * @param underlyingStream * @return * @throws Exception */ public InputStream getCheckoutStream(FcsContext context,Location info,InputStream underlyingStream) throws Exception; /** * Called when the fcs is doing a checkin. The implementation can either act as an end point or a filter. * The implementation needs to use the underlying stream to get the actual data * * @param context * @param location * @param outp * @return * @throws FcsException */ public OutputStream getCheckinStream(FcsContext context,Location location,OutputStream outp) throws FcsException; /** * Called when creating the filter. The params parameter contains the filter params * section as defined in the store definition * @param info * @param params * @Deprecated Do not implement, will be removed in R2020x, Use signature with org.w3c.dom.Element */ @Deprecated public default void init(Location info, com.matrixone.jdom.Element params){} /** * Called when creating the filter. The params parameter contains the filter params * section as defined in the store definition * @param info * @param params */ public default void init(Location info, org.w3c.dom.Element params){}; } In sample filters please replace the current one by these ones: import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.w3c.dom.Element; import com.matrixone.fcs.common.FcsException; import com.matrixone.fcs.fcs.FCSStreamFilter; import com.matrixone.fcs.fcs.FcsContext; public class TestFilter implements FCSStreamFilter { private Element _params; class MyFilteredOutputStream extends FilterOutputStream { private int _bytesWritten; public MyFilteredOutputStream(OutputStream out) { super(out); } public void write(byte[] b, int off, int len) throws IOException { super.write(b, off, len); _bytesWritten+= len; } } public OutputStream getCheckinStream(FcsContext context, OutputStream underlyingStream) throws FcsException { return new MyFilteredOutputStream(underlyingStream); } public InputStream getCheckoutStream(FcsContext context, InputStream underlyingStream) throws Exception { return underlyingStream; } public void init(Element params) { _params = params; } } and for the zip sample, just replace
|