Example #1
0
        protected void Initialize(Logger Log, FqStreamID FQSID,
                                  int num, CallerInfo Ci, LocationInfo Li,
                                  StreamFactory.StreamOp op, StreamFactory.StreamSecurityType type,
                                  CompressionType ctype, int ChunkSizeForUpload, int ThreadPoolSize)
        {
            // Logging related
            logger = Log;
            if (logger != null)
            {
                logger.Log("Start ValueDataStream Init DataStructures");
            }

            // Naming related
            streamid        = FQSID;
            stream          = new MetaDataService.FQStreamID();
            stream.HomeId   = FQSID.HomeId;
            stream.AppId    = FQSID.AppId;
            stream.StreamId = FQSID.StreamId;
            BaseDir         = Path.GetFullPath((null != Ci.workingDir) ? Ci.workingDir : Directory.GetCurrentDirectory());
            targetDir       = BaseDir + "/" + streamid.ToString();
            seq_num         = num;
            targetDir       = targetDir + "/" + seq_num;
            if (!Directory.Exists(targetDir))
            {
                Directory.CreateDirectory(targetDir);
            }

            // Ownership related
            caller        = new MetaDataService.Principal();
            caller.HomeId = streamid.HomeId;
            caller.AppId  = Ci.appName;
            owner         = new MetaDataService.Principal();
            owner.HomeId  = streamid.HomeId;
            owner.AppId   = streamid.AppId;

            // Location
            account             = new MetaDataService.AccountInfo();
            account.accountName = Li.accountName;
            account.accountKey  = Li.accountKey;
            account.location    = "" + Li.st;

            // Index related
            index     = new Dictionary <IKey, List <DataBlockInfo> >();
            t_s       = StreamFactory.NowUtc();
            t_e       = 0;
            IndexHash = null;
            isSealed  = false;

            // Low level
            hasher = new SHA256CryptoServiceProvider();

            // State maint
            streamop              = op;
            streamtype            = type;
            streamcompressiontype = ctype;

            //sync related
            this.StreamChunkSizeForUpload = ChunkSizeForUpload;
            this.StreamThreadPoolSize     = ThreadPoolSize;
        }
 public void Setup()
 {
     k1 = new StrKey("k1");
     k2 = new StrKey("k2");
     string AzureaccountName = "testdrive";
     string AzureaccountKey = "zRTT++dVryOWXJyAM7NM0TuQcu0Y23BgCQfkt7xh2f/Mm+r6c8/XtPTY0xxaF6tPSACJiuACsjotDeNIVyXM8Q==";
     locationInfo = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);
     streamID = new FqStreamID("99-a2000", "A0", "TestDS");
     callerInfo = new CallerInfo(null, "A0", "A0", 1);
     streamSecurityType = StreamFactory.StreamSecurityType.Plain;
     streamFactory = StreamFactory.Instance;
 }
Example #3
0
 public void Setup()
 {
     k1 = new StrKey("k1");
     k2 = new StrKey("k2");
     string AzureaccountName = "msrlot";
     string AzureaccountKey = "wC3ou+VLBTu8ryKbsiSMtsIIHIpxGSIAWA0NtK58da2wELQ+USgYQwmVMtyq/p8ILsuZc8TiLeHBjaPI+a3A2Q==";
     locationInfo = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);
     streamID = new FqStreamID("99-a2000", "A0", "TestDS");
     callerInfo = new CallerInfo(null, "A0", "A0", 1);
     streamSecurityType = StreamFactory.StreamSecurityType.Plain;
     streamFactory = StreamFactory.Instance;
 }
Example #4
0
        public void Setup()
        {
            k1 = new StrKey("k1");
            k2 = new StrKey("k2");
            string AzureaccountName = "testdrive";
            string AzureaccountKey  = "zRTT++dVryOWXJyAM7NM0TuQcu0Y23BgCQfkt7xh2f/Mm+r6c8/XtPTY0xxaF6tPSACJiuACsjotDeNIVyXM8Q==";

            locationInfo       = new LocationInfo(AzureaccountName, AzureaccountKey, SynchronizerType.Azure);
            streamID           = new FqStreamID("99-a2000", "A0", "TestDS");
            callerInfo         = new CallerInfo(null, "A0", "A0", 1);
            streamSecurityType = StreamFactory.StreamSecurityType.Plain;
            streamFactory      = StreamFactory.Instance;
        }
Example #5
0
 public FileDataStream(Logger Log, FqStreamID FQSID, int num,
                       CallerInfo Ci, LocationInfo Li,
                       StreamFactory.StreamOp op, StreamFactory.StreamSecurityType type,
                       CompressionType ctype, int ChunkSizeForUpload, int UploadThreadPoolSize,
                       string prkey, string pukey, MetaDataService.ACLEntry key_md,
                       IndexInfo ii, bool alreadyExists = true)
     : base(Log, FQSID, num, Ci, Li, op, type, ctype, ChunkSizeForUpload, UploadThreadPoolSize,
            prkey, pukey, key_md, ii, alreadyExists: alreadyExists)
 {
     remoteRead = false;
     // if remote stream, read op. fetch valueFile when needed for get queries
     if (this.synchronizer != null && streamop == StreamFactory.StreamOp.Read)
     {
         remoteRead = true;
     }
 }
Example #6
0
        public ValueDataStream(Logger Log, FqStreamID FQSID, int num,
                               CallerInfo Ci, LocationInfo Li,
                               StreamFactory.StreamOp op, StreamFactory.StreamSecurityType type,
                               CompressionType ctype, int ChunkSizeForUpload, int UploadThreadPoolSize,
                               string prkey, string pukey, MetaDataService.ACLEntry key_md,
                               IndexInfo ii,
                               bool alreadyExists = true)
        {
            Initialize(Log, FQSID, num, Ci, Li, op, type, ctype, ChunkSizeForUpload, UploadThreadPoolSize);

            if (streamtype == StreamFactory.StreamSecurityType.Secure)
            {
                // Key related
                OwnerPriKey = prkey;
                OwnerPubKey = pukey;
                acl_md      = key_md;
            }
            if (logger != null)
            {
                logger.Log("End ValueDataStream Init DataStructures");
            }

            // Fetch data
            FetchAndFillIndex(ii, alreadyExists);

            // Reset sync to upload
            if (op == StreamFactory.StreamOp.Write)
            {
                CreateSync(SynchronizeDirection.Upload);
            }

            isClosed = false;
            if (logger != null)
            {
                logger.Log("Start ValueDataStream ReadFromDisk Open");
            }
            OpenStream();
            if (logger != null)
            {
                logger.Log("End ValueDataStream ReadFromDisk Open");
            }
            disposed = false;
        }
Example #7
0
 /* syncIntervalSec:
  *   -ve ==> don't sync on writes;  only sync on close.
  *   0   ==> sync on every write
  *   +ve ==> sync every x seconds
  *
  * Throws System.Exception e.g., on network disconnection for remote streams. Catch in Caller.
  */
 public IStream openFileDataStream <KeyType>(FqStreamID FQSID,
                                             CallerInfo Ci,
                                             LocationInfo Li,
                                             StreamFactory.StreamSecurityType type,
                                             CompressionType ctype,
                                             StreamFactory.StreamOp op,
                                             string mdserveraddress = null,
                                             int ChunkSizeForUpload = 4 *1024 *1024,
                                             int ThreadPoolSize     = 1,
                                             Logger log             = null,
                                             bool sideload          = false,
                                             int syncIntervalSec    = -1)
     where KeyType : IKey, new()
 {
     if (Li == null)
     {
         Li = new LocationInfo("", "", SynchronizerType.None);
     }
     return(new MetaStream <KeyType, ByteValue>(FQSID, Ci, Li,
                                                op, type, ctype, StreamDataType.Files,
                                                syncIntervalSec, mdserveraddress,
                                                ChunkSizeForUpload, ThreadPoolSize,
                                                log, sideload));
 }