8 Replies Latest reply on Nov 21, 2017 1:01 PM by Joseph Peters

    Unable to extract multiple files in one session

    Joseph Peters

      Hi.

       

      I'm using the Java SDK to create .tde files.  I have successfully created a .tde, but I'm unable to create more than one in a single session. 

      This is a portion of the code I'm using:

      {
      ExtractAPI.initialize();
      TableDefinition schema = new TableDefinition();
      Extract extract = new Extract("c:\\temp\\one_test.tde");
      
      schema.addColumn("One",Type.INTEGER);
      Table table = null;
      table = extract.addTable("Extract", schema);
      
      Row row = new Row(schema);
      
      row.setInteger(0, 42);
      table.insert(row);
      extract.close();
      ExtractAPI.cleanup();
      }
      
      {
      ExtractAPI.initialize();
      TableDefinition schema = new TableDefinition();
      Extract extract = new Extract("c:\\temp\\two_test.tde");
      
      schema.addColumn("One",Type.INTEGER);
      Table table = null;
      table = extract.addTable("Extract", schema);
      
      Row row = new Row(schema);
      
      row.setInteger(0, 43);
      table.insert(row);
      extract.close();
      ExtractAPI.cleanup();
      }
      

       

      Usually, this will produce the following error upon the second "new Extract()" call (line 21 above).

      com.tableausoftware.TableauException: IPC_NamedPipe::Select(WaitForMultipleObjects): Timeout

       

      I never get this error on the first file, only the second, and it happens maybe 90% of the time.

       

      I've tried only calling ExtractAPI.initialize() and .cleanup() once at the beginning and end, but it does not change the result.

       

      Any assistance will be appreciated.

        • 1. Re: Unable to extract multiple files in one session
          Tom W

          Are you sure your program is waiting for the file extract to close and cleanup? It's not really possible to tell from the snippets you've included.

          • 2. Re: Unable to extract multiple files in one session
            Joseph Peters

            Thanks for your reply!

             

            No, I'm not waiting after the extract is closed.  I assumed the close() call wouldn't return until it was done.  Is there any way to tell if it's complete?

            • 3. Re: Unable to extract multiple files in one session
              Tom W

              It depends on whether or not your code is designed to execute synchronously or asynchronously, I can't really tell from your snippets above if those are functions being called somewhere else or if they are meant to run in a linear fashion. Perhaps you should only be initializing the ExtractApi once , do extract one, close extract one, define extract2 (use a new name), do extract2 stuff...... cleanup API

               

              If you're just straight up running this all in the same code block then I would also expect that the next extract wouldn't be initialized until the close is complete.

              1 of 1 people found this helpful
              • 4. Re: Unable to extract multiple files in one session
                Joseph Peters

                I'm executing the code exactly as it is above -- sequentially, in a single thread.

                 

                But you might be on to something.  I put a "Thread.sleep(5000)" between the two blocks, and I'm having greater success.  It appears that either the .close() or .cleanup() call is still doing something after it returns.

                • 5. Re: Unable to extract multiple files in one session
                  Tom W

                  I'd try the other approach as I outlined it above - define and initialize the extractapi once and don't cleanup until both extracts are created. Define your second extract using a unique name.

                  1 of 1 people found this helpful
                  • 6. Re: Unable to extract multiple files in one session
                    Joseph Peters

                    No luck -- this is what I have now, and it still produces the error:

                    ExtractAPI.initialize();

                     

                    TableDefinition schema = new TableDefinition();

                    Extract extract = new Extract("c:\\temp\\one_test.tde");

                    schema.addColumn("One",Type.INTEGER);

                    Table table = null;

                    table = extract.addTable("Extract", schema);

                    Row row = new Row(schema);

                    row.setInteger(0, 42);

                    table.insert(row);

                    extract.close();

                     

                    TableDefinition schema2 = new TableDefinition();

                    Extract extract2 = new Extract("c:\\temp\\two_test.tde");

                    schema2.addColumn("One",Type.INTEGER);

                    Table table2 = null;

                    table2 = extract2.addTable("Extract", schema2);

                    Row row2 = new Row(schema2);

                    row2.setInteger(0, 43);

                    table2.insert(row2);

                    extract2.close();

                     

                    ExtractAPI.cleanup();

                     

                    The only thing that seems to work consistently is adding the Thread.sleep() call between the blocks:

                     

                    ExtractAPI.initialize();

                     

                    TableDefinition schema = new TableDefinition();

                    Extract extract = new Extract("c:\\temp\\one_test.tde");

                    schema.addColumn("One",Type.INTEGER);

                    Table table = null;

                    table = extract.addTable("Extract", schema);

                    Row row = new Row(schema);

                    row.setInteger(0, 42);

                    table.insert(row);

                    extract.close();

                     

                    Thread.sleep(10000);

                     

                    TableDefinition schema2 = new TableDefinition();

                    Extract extract2 = new Extract("c:\\temp\\two_test.tde");

                    schema2.addColumn("One",Type.INTEGER);

                    Table table2 = null;

                    table2 = extract2.addTable("Extract", schema2);

                    Row row2 = new Row(schema2);

                    row2.setInteger(0, 43);

                    table2.insert(row2);

                    extract2.close();

                     

                    ExtractAPI.cleanup();

                    • 7. Re: Unable to extract multiple files in one session
                      Tom W

                      I don't know enough about Java to help you take this any further unfortunately. It seems like the program isn't waiting for the extract close call to complete and I don't know how to force that behavior in Java.

                      Perhaps it's a good idea to do a loop and TRY command for your second extract so you try to create the new extract, if it fails, sleep, try again... repeat for a few iterations.

                      • 8. Re: Unable to extract multiple files in one session
                        Joseph Peters

                        Yes, I was thinking of doing the same if my existing timeout approach was insufficient.  It's dirty, but if it works, it works....

                         

                        Thanks for your help.