[ 
https://issues.apache.org/jira/browse/BEAM-12988?focusedWorklogId=661000&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-661000
 ]

ASF GitHub Bot logged work on BEAM-12988:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Oct/21 15:28
            Start Date: 06/Oct/21 15:28
    Worklog Time Spent: 10m 
      Work Description: AydarZaynutdinov commented on a change in pull request 
#15645:
URL: https://github.com/apache/beam/pull/15645#discussion_r723396311



##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -0,0 +1,113 @@
+// 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 fs_tool
+
+import (
+       pb "beam.apache.org/playground/backend/internal/api"
+       "fmt"
+       "github.com/google/uuid"
+       "io/fs"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+)
+
+const parentBaseFileFolder = "internal"
+
+// Folder contains  names of folders with executable and compiled files (/src 
and /bin for java SDK)
+type Folder struct {
+       ExecutableFolder string
+       CompiledFolder   string
+}
+
+// Extension contains executable and compiled files' extensions (.java and 
.class for java SDK)
+type Extension struct {
+       ExecutableExtension string
+       CompiledExtension   string
+}
+
+type LifeCycle struct {
+       folderGlobs *[]string

Review comment:
       Done.

##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -0,0 +1,113 @@
+// 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 fs_tool
+
+import (
+       pb "beam.apache.org/playground/backend/internal/api"
+       "fmt"
+       "github.com/google/uuid"
+       "io/fs"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+)
+
+const parentBaseFileFolder = "internal"
+
+// Folder contains  names of folders with executable and compiled files (/src 
and /bin for java SDK)
+type Folder struct {
+       ExecutableFolder string
+       CompiledFolder   string
+}
+
+// Extension contains executable and compiled files' extensions (.java and 
.class for java SDK)
+type Extension struct {
+       ExecutableExtension string
+       CompiledExtension   string
+}
+
+type LifeCycle struct {
+       folderGlobs *[]string
+       Folder      Folder
+       Extension   Extension
+       pipelineId  uuid.UUID
+}
+
+// NewLifeCycle returns a corresponding LifeCycle depending on the given SDK.
+func NewLifeCycle(sdk pb.Sdk, pipelineId uuid.UUID) (*LifeCycle, error) {
+       switch sdk {
+       case pb.Sdk_SDK_JAVA:
+               return newJavaLifeCycle(pipelineId), nil
+       default:
+               return nil, fmt.Errorf("%s isn't supported now", sdk)
+       }
+}
+
+// CreateFolders creates all folder by folderGlobs.
+func (l *LifeCycle) CreateFolders() error {
+       for _, folder := range *l.folderGlobs {
+               err := os.MkdirAll(folder, fs.ModePerm)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+// DeleteFolders deletes all folder by folderGlobs.

Review comment:
       Done.

##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -0,0 +1,113 @@
+// 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 fs_tool
+
+import (
+       pb "beam.apache.org/playground/backend/internal/api"
+       "fmt"
+       "github.com/google/uuid"
+       "io/fs"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+)
+
+const parentBaseFileFolder = "internal"
+
+// Folder contains  names of folders with executable and compiled files (/src 
and /bin for java SDK)
+type Folder struct {
+       ExecutableFolder string
+       CompiledFolder   string
+}
+
+// Extension contains executable and compiled files' extensions (.java and 
.class for java SDK)
+type Extension struct {
+       ExecutableExtension string
+       CompiledExtension   string
+}
+
+type LifeCycle struct {
+       folderGlobs *[]string
+       Folder      Folder
+       Extension   Extension
+       pipelineId  uuid.UUID
+}
+
+// NewLifeCycle returns a corresponding LifeCycle depending on the given SDK.
+func NewLifeCycle(sdk pb.Sdk, pipelineId uuid.UUID) (*LifeCycle, error) {
+       switch sdk {
+       case pb.Sdk_SDK_JAVA:
+               return newJavaLifeCycle(pipelineId), nil
+       default:
+               return nil, fmt.Errorf("%s isn't supported now", sdk)
+       }
+}
+
+// CreateFolders creates all folder by folderGlobs.
+func (l *LifeCycle) CreateFolders() error {
+       for _, folder := range *l.folderGlobs {
+               err := os.MkdirAll(folder, fs.ModePerm)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+// DeleteFolders deletes all folder by folderGlobs.
+func (l *LifeCycle) DeleteFolders() error {
+       for _, folder := range *l.folderGlobs {
+               err := os.RemoveAll(folder)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+// CreateExecutableFile creates executable file (file.java for java SDK).

Review comment:
       Done.

##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -0,0 +1,113 @@
+// 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 fs_tool
+
+import (
+       pb "beam.apache.org/playground/backend/internal/api"
+       "fmt"
+       "github.com/google/uuid"
+       "io/fs"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+)
+
+const parentBaseFileFolder = "internal"
+
+// Folder contains  names of folders with executable and compiled files (/src 
and /bin for java SDK)
+type Folder struct {
+       ExecutableFolder string
+       CompiledFolder   string
+}
+
+// Extension contains executable and compiled files' extensions (.java and 
.class for java SDK)
+type Extension struct {
+       ExecutableExtension string
+       CompiledExtension   string
+}
+
+type LifeCycle struct {
+       folderGlobs *[]string
+       Folder      Folder
+       Extension   Extension
+       pipelineId  uuid.UUID
+}
+
+// NewLifeCycle returns a corresponding LifeCycle depending on the given SDK.
+func NewLifeCycle(sdk pb.Sdk, pipelineId uuid.UUID) (*LifeCycle, error) {
+       switch sdk {
+       case pb.Sdk_SDK_JAVA:
+               return newJavaLifeCycle(pipelineId), nil
+       default:
+               return nil, fmt.Errorf("%s isn't supported now", sdk)
+       }
+}
+
+// CreateFolders creates all folder by folderGlobs.
+func (l *LifeCycle) CreateFolders() error {
+       for _, folder := range *l.folderGlobs {
+               err := os.MkdirAll(folder, fs.ModePerm)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+// DeleteFolders deletes all folder by folderGlobs.
+func (l *LifeCycle) DeleteFolders() error {
+       for _, folder := range *l.folderGlobs {
+               err := os.RemoveAll(folder)
+               if err != nil {
+                       return err
+               }
+       }
+       return nil
+}
+
+// CreateExecutableFile creates executable file (file.java for java SDK).
+func (l *LifeCycle) CreateExecutableFile(code string) (string, error) {
+       if _, err := os.Stat(l.Folder.ExecutableFolder); os.IsNotExist(err) {
+               return "", err
+       }
+
+       fileName := getFileName(l.pipelineId, l.Extension.ExecutableExtension)
+       filePath := filepath.Join(l.Folder.ExecutableFolder, fileName)
+       err := ioutil.WriteFile(filePath, []byte(code), 0600)

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 661000)
    Time Spent: 2.5h  (was: 2h 20m)

> Implement FileSystem service
> ----------------------------
>
>                 Key: BEAM-12988
>                 URL: https://issues.apache.org/jira/browse/BEAM-12988
>             Project: Beam
>          Issue Type: Sub-task
>          Components: beam-playground
>            Reporter: Ilya Kozyrev
>            Assignee: Aydar Zaynutdinov
>            Priority: P3
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> We need to have a go module that helps us to communicate with the file system.
>  
> Server and controller take code as a string, but executor requires the 
> prepared folder structure on fs and Java code located in the file. For this 
> purpose, we need to implement an additional module that will be responsible 
> for that.
> This module should have the following functionality:
>  * Take SDK in the constructor and be able to manage functionality depends on 
> SDK.
>  * Create directory structure on fs for specific SDK. This structure will use 
> for compilation and running code.
>  * Write Java code from string to file on FS
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to