Package org.exoplatform.services.jcr.impl.dataflow.persistent

Examples of org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData


         if (i == Math.round(count / 2))
            propertyId = pid;

         FileIOChannel fch = openCASChannel(digestType);
         fch.write(pid,
            new StreamPersistedValueData(0, new FileInputStream(testFile), SpoolConfig.getDefaultSpoolConfig()));
         fch.commit();
      }

      // remove mapping in VCAS for one of files
      FileIOChannel fch = openCASChannel(digestType);
View Full Code Here


         File f = createBLOBTempFile(fileSizeKb);
         addedSize += (fileSize = f.length());

         FileIOChannel fch = openCASChannel(digestType);
         fch.write(pid, new StreamPersistedValueData(i, new FileInputStream(f), SpoolConfig.getDefaultSpoolConfig()));
         fch.commit();
      }

      // remove mapping in VCAS for one of files
      FileIOChannel fch = openCASChannel(digestType);
View Full Code Here

      FileIOChannel fch = openCASChannel(digestType);

      final String property1MultivaluedId = IdGenerator.generate();

      StreamPersistedValueData sharedValue = null;

      // add multivaued property
      long m1fileSize = 0;
      long m1filesCount = 0;
      long addedSize = 0;
      for (int i = 0; i < 5; i++)
      {
         File f = createBLOBTempFile(450);
         addedSize += (m1fileSize = f.length());

         StreamPersistedValueData v =
            new StreamPersistedValueData(i, new FileInputStream(f), SpoolConfig.getDefaultSpoolConfig());

         if (i == 1)
            sharedValue = v;
         else
            m1filesCount++;

         fch.write(property1MultivaluedId, v);
      }
      fch.commit();

      // add another multivalued with shared file
      final String property2MultivaluedId = IdGenerator.generate();
      long m2fileSize = 0;
      long m2filesCount = 0;
      fch = openCASChannel(digestType);
      for (int i = 0; i < 4; i++)
      {
         ValueData v;
         if (i == 2)
         {
            // use shared
            sharedValue =
               new StreamPersistedValueData(i, sharedValue.getAsStream(), SpoolConfig.getDefaultSpoolConfig());
            v = sharedValue;
         }
         else
         {
            // new file
            m2filesCount++;
            File f = createBLOBTempFile(350);
            addedSize += (m2fileSize = f.length()); // add size
            v = new StreamPersistedValueData(i, new FileInputStream(f), SpoolConfig.getDefaultSpoolConfig());
         }
         fch.write(property2MultivaluedId, v);
      }
      fch.commit();

      // add some single valued properties, two new property will have shared value too
      String property1Id = null;
      String property2Id = null;
      sharedValue = new StreamPersistedValueData(0, sharedValue.getAsStream(), SpoolConfig.getDefaultSpoolConfig());
      for (int i = 0; i < 10; i++)
      {
         String pid = IdGenerator.generate();
         ValueData v;
         if (i == 1)
         {
            property1Id = pid;
            v = sharedValue;
         }
         else if (i == 5)
         {
            property2Id = pid;
            v = sharedValue;
         }
         else
         {
            File f = createBLOBTempFile(425);
            addedSize += f.length();
            v = new StreamPersistedValueData(i, new FileInputStream(f), SpoolConfig.getDefaultSpoolConfig());
         }
         FileIOChannel vfch = openCASChannel(digestType);
         vfch.write(pid, v);
         vfch.commit();
      }
View Full Code Here

               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile =
                  SwapFile.get(this.containerConfig.spoolConfig.tempDirectory,
                     cid + i + "." + data.getPersistedVersion(),this.containerConfig.spoolConfig.fileCleaner);
               try
               {
                  long vlen = WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
                  if (vlen <= Integer.MAX_VALUE)
                  {
                     streamLength = (int)vlen;
                  }
                  else
                  {
                     throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                        + ". Property " + data.getQPath().getAsString());
                  }
               }
               finally
               {
                  swapFile.spoolDone();
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
            sizeHandler.accumulateNewSize(streamLength);
         }
         else
View Full Code Here

               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile =
                  SwapFile.get(this.containerConfig.spoolConfig.tempDirectory,
                     cid + i + "." + data.getPersistedVersion(),this.containerConfig.spoolConfig.fileCleaner);
               try
               {
                  long vlen = WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
                  if (vlen <= Integer.MAX_VALUE)
                  {
                     streamLength = (int)vlen;
                  }
                  else
                  {
                     throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                        + ". Property " + data.getQPath().getAsString());
                  }
               }
               finally
               {
                  swapFile.spoolDone();
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
            sizeHandler.accumulateNewSize(streamLength);
         }
         else
View Full Code Here

   protected void writeStreamedValue(File file, ValueData value) throws IOException
   {
      // stream Value
      if (value instanceof StreamPersistedValueData)
      {
         StreamPersistedValueData streamed = (StreamPersistedValueData)value;

         if (streamed.isPersisted())
         {
            // already persisted in another Value, copy it to this Value
            copyClose(streamed.getAsStream(), new FileOutputStream(file));
         }
         else
         {
            // the Value not yet persisted, i.e. or in client stream or spooled to a temp file
            File tempFile;
            if ((tempFile = streamed.getTempFile()) != null)
            {
               // it's spooled Value, try move its file to VS
               if (!tempFile.renameTo(file))
               {
                  // not succeeded - copy bytes, temp file will be deleted by transient ValueData
                  if (LOG.isDebugEnabled())
                  {
                     LOG
                        .debug("Value spool file move (rename) to Values Storage is not succeeded. Trying bytes copy. Spool file: "
                           + tempFile.getAbsolutePath() + ". Destination: " + file.getAbsolutePath());
                  }

                  copyClose(new FileInputStream(tempFile), new FileOutputStream(file));
               }
            }
            else
            {
               // not spooled, use client InputStream
               copyClose(streamed.getStream(), new FileOutputStream(file));
            }

            // link this Value to file in VS
            streamed.setPersistedFile(file);
         }
      }
      else
      {
         // copy from Value stream to the file, e.g. from FilePersistedValueData to this Value
View Full Code Here

      {
         InputStream in;
         if (value instanceof StreamPersistedValueData)
         {

            StreamPersistedValueData streamed = (StreamPersistedValueData)value;
            if (streamed.isPersisted())
            {
               // already persisted in another Value, copy it to this Value
               in = streamed.getAsStream();
            }
            else
            {
               in = streamed.getStream();
               if (in == null)
               {
                  in = new FileInputStream(streamed.getTempFile());
               }
            }
         }
         else
         {
View Full Code Here

               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." + data.getPersistedVersion(),swapCleaner);
               try
               {
                  WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
               }
               finally
               {
                  swapFile.spoolDone();
               }

               long vlen = PrivilegedFileHelper.length(swapFile);
               if (vlen <= Integer.MAX_VALUE)
               {
                  streamLength = (int)vlen;
               }
               else
               {
                  throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                     + ". Property " + data.getQPath().getAsString());
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
         }
         else
         {
View Full Code Here

               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile =
                  SwapFile.get(this.containerConfig.spoolConfig.tempDirectory,
                     cid + i + "." + data.getPersistedVersion(),this.containerConfig.spoolConfig.fileCleaner);
               try
               {
                  long vlen = WRITE_VALUE_HELPER.writeStreamedValue(swapFile, streamData);
                  if (vlen <= Integer.MAX_VALUE)
                  {
                     streamLength = (int)vlen;
                  }
                  else
                  {
                     throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                        + ". Property " + data.getQPath().getAsString());
                  }
               }
               finally
               {
                  swapFile.spoolDone();
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
            sizeHandler.accumulateNewSize(streamLength);
         }
         else
View Full Code Here

               stream = new ByteArrayInputStream(dataBytes);
               streamLength = dataBytes.length;
            }
            else
            {
               StreamPersistedValueData streamData = (StreamPersistedValueData)vd;

               SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." + data.getPersistedVersion());
               try
               {
                  writeValueHelper.writeStreamedValue(swapFile, streamData);
               }
               finally
               {
                  swapFile.spoolDone();
               }

               long vlen = PrivilegedFileHelper.length(swapFile);
               if (vlen <= Integer.MAX_VALUE)
               {
                  streamLength = (int)vlen;
               }
               else
               {
                  throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
                     + ". Property " + data.getQPath().getAsString());
               }

               stream = streamData.getAsStream();
            }
            storageId = null;
         }
         else
         {
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.