This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Property Name | Default | Meaning | |
---|---|---|---|
spark.dynamicAllocation.enabled | FALSE | Whether to use dynamic resource allocation, which scales the number of executors registered with this application up and down based on the workload | |
spark.dynamicAllocation.executorIdleTimeout | 60s | If dynamic allocation is enabled and an executor has been idle for more than this duration, the executor will be removed | |
spark.dynamicAllocation.initialExecutors | minExecutors | Initial number of executors to run if dynamic allocation is enabled.Ê | |
spark.dynamicAllocation.minExecutors | 0 | Lower bound for the number of executors if dynamic allocation is enabled. | |
spark.dynamicAllocation.schedulerBacklogTimeout | 1s | If dynamic allocation is enabled and there have been pending tasks backlogged for more than this duration, new executors will be requested. | |
spark.dynamicAllocation.sustainedSchedulerBacklogTimeout | schedulerBacklogTimeout | Same asÊspark.dynamicAllocation.schedulerBacklogTimeout, but used only for subsequent executor requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/labstack/echo" | |
) | |
//main function | |
func main() { | |
// create a new echo instance | |
e := echo.New() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//GET API which return the name of the cats specified in QueryParam | |
//http://localhost:8000/cats?name=arnold&type=fluffy | |
func GetCats(c echo.Context) error { | |
catName := c.QueryParam("name") | |
catType := c.QueryParam("type") | |
return c.String(http.StatusOK, fmt.Sprintf("your cat name is : %s\nand cat type is : %s\n", catName, catType)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://localhost:8000/cats/json?name=arnold&type=fluffy | |
//data path variable accepts value as json/string | |
func GetCats(c echo.Context) error { | |
catName := c.QueryParam("name") | |
catType := c.QueryParam("type") | |
dataType := c.Param("data") | |
if dataType == "string" { | |
return c.String(http.StatusOK, fmt.Sprintf("your cat name is : %s\nand cat type is : %s\n", catName, catType)) | |
} else if dataType == "json" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func AddCat(c echo.Context) error { | |
type Cat struct { | |
Name string `json:"name"` | |
Type string `json:"type"` | |
} | |
cat := Cat{} | |
defer c.Request().Body.Close() | |
err := json.NewDecoder(c.Request().Body).Decode(&cat) | |
if err != nil { | |
log.Fatalf("Failed reading the request body %s", err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/labstack/echo" | |
"fmt" | |
"net/http" | |
) | |
func main() { | |
// create a new echo instance | |
e := echo.New() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Custom Middleware | |
// ServerHeader middleware adds a custom header to the response. | |
func serverHeader(next echo.HandlerFunc) echo.HandlerFunc { | |
return func(c echo.Context) error { | |
c.Response().Header().Set("Custom-Header", "blah!!!") | |
return next(c) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "city") | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
@JsonInclude(JsonInclude.Include.NON_NULL) | |
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "string")}) | |
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId") | |
public class City implements Serializable,TenantSupport { | |
private static final long serialVersionUID = -4551953276601557391L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Aspect | |
@Component | |
public class CityServiceAspect { | |
@Before("execution(* com.example.service.discriminator.CityService.*(..))&& target(cityService) ") | |
public void aroundExecution(JoinPoint pjp, CityService cityService) throws Throwable { | |
org.hibernate.Filter filter = cityService.entityManager.unwrap(Session.class).enableFilter("tenantFilter"); | |
filter.setParameter("tenantId", TenantContext.getCurrentTenant()); | |
filter.validate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class MyInterceptor { | |
@Autowired | |
private JpaProperties jpaProperties; | |
@Bean | |
public EmptyInterceptor hibernateInterceptor() { | |
return new EmptyInterceptor() { |
OlderNewer